Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Can't compile when including transaction.hpp #486

Closed
jasonbert opened this issue Apr 3, 2019 · 8 comments
Closed

Can't compile when including transaction.hpp #486

jasonbert opened this issue Apr 3, 2019 · 8 comments

Comments

@jasonbert
Copy link

Using the test contract below, I'm unable to compile when including <eosio/transaction.hpp>.

/usr/opt/eosio.cdt/1.6.1/bin/wasm-ld: error: duplicate symbol: eosio::send_deferred(unsigned __int128 const&, eosio::name, char const*, unsigned int, bool)
>>> defined in /tmp/test.cpp.o
>>> defined in /tmp/test.cpp.o
#include <eosio/contract.hpp>
#include <eosio/transaction.hpp>

using namespace eosio;

namespace test {
    class [[eosio::contract]] test : public contract {
        public:
            test(name receiver, name code, datastream<const char*> ds) : contract(receiver, code, ds) { }

            ACTION testact( name user ) {
                require_auth( user );
            }
    };
}
@jasonbert
Copy link
Author

If I switch back to the eosiolib includes, the build passes and as expected you get the deprecation warnings.

#include <eosiolib/contract.hpp>
#include <eosiolib/transaction.hpp>

@smlu
Copy link
Contributor

smlu commented Apr 6, 2019

The error you're getting is due to small bug in the declaration of send_deferred function which is defined in file eosiolib/contracts/eosio/transaction.hpp:175. Because this function is defined in header file it should be declared as inline (or static) function but it's not. That's why linker then finds multiple declaration of send_deferred function.

This issue is fixed in PR #479

@johndebord
Copy link
Contributor

@jasonbert Could you give more details on which operating system you are currently using, as well as any other information that you think may be pertinent? I am unable to reproduce the error on my machine.

@jasonbert
Copy link
Author

  • Windows 10 Pro 1803 (Build: 17134.648)
  • Windows Subsystem for Linux (WSL) with Ubuntu 18.04

I don't think it would make a difference, but I was editing with Visual Studio Code. The compilation is all run through the Bash shell WSL provides. There's possibly something VS Code is doing to supply include paths, I was using a c_cpp_properties.json (part of the C++ VS Code extension). I was able to compile by calling eosio-cpp -g /mnt/c/Work/git/contracts/token/src/token.cpp -abigen from within VS Code.

I've cleaned up my WSL and reinstalled EOS & EOSIO.CDT, now I can run eosio-cpp -abigen -I include -L /usr/opt/eosio.cdt/1.6.1/include/eosiolib/contracts/eosio -contract token -o token.wasm src/token.cpp without issue. The contract is using the <eosio\...> include declaration.

To be fair, this could have been localised to my WSL install. Although, interesting @smlu has identified the probable problem. I have also switched to using EOS Studio, which builds via Docker, so I'm not blocked anymore :).

@mgravitt
Copy link

mgravitt commented Jun 3, 2019

I am blocked on this issue. I am getting the below errors. I am using cmake and I don't think EOS Studio is a workaround in my case. You can replicate the issue by cloning the following repo and running make (https://github.com/gyftie/gyftie-contracts2). I am looking for a workaround. thanks

>>> defined in CMakeFiles/gyftietoken.dir/gyftietoken.cpp.obj
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/profile.cpp.obj

/usr/local/Cellar/eosio.cdt/1.6.1/opt/eosio.cdt/bin/wasm-ld: error: duplicate symbol: eosio::send_deferred(unsigned __int128 const&, eosio::name, char const*, unsigned int, bool)
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/profile.cpp.obj
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/gyft.cpp.obj

/usr/local/Cellar/eosio.cdt/1.6.1/opt/eosio.cdt/bin/wasm-ld: error: duplicate symbol: eosio::send_deferred(unsigned __int128 const&, eosio::name, char const*, unsigned int, bool)
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/gyft.cpp.obj
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/proposal.cpp.obj

/usr/local/Cellar/eosio.cdt/1.6.1/opt/eosio.cdt/bin/wasm-ld: error: duplicate symbol: eosio::send_deferred(unsigned __int128 const&, eosio::name, char const*, unsigned int, bool)
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/proposal.cpp.obj
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/reputation.cpp.obj

/usr/local/Cellar/eosio.cdt/1.6.1/opt/eosio.cdt/bin/wasm-ld: error: duplicate symbol: eosio::send_deferred(unsigned __int128 const&, eosio::name, char const*, unsigned int, bool)
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/reputation.cpp.obj
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/lock.cpp.obj

/usr/local/Cellar/eosio.cdt/1.6.1/opt/eosio.cdt/bin/wasm-ld: error: duplicate symbol: eosio::send_deferred(unsigned __int128 const&, eosio::name, char const*, unsigned int, bool)
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/lock.cpp.obj
>>> defined in CMakeFiles/gyftietoken.dir/__/classes/gyftie.cpp.obj
make[5]: *** [gyftietoken/gyftietoken.wasm] Error 255```

@jeffreyssmith2nd
Copy link
Contributor

I am blocked on this issue. I am getting the below errors. I am using cmake ...

Can you try again with v1.6.2? I just cloned the repo and was able to successfully build with 1.6.2. There were deprecation warnings about get_code but none of the issues with duplicate symobls.

@mgravitt
Copy link

When I put all my code in the header files instead of in cpp files, it works. But as it does not work when the code uses the transaction object and additional cpp files. Not sure the root cause, but it is really annoying.

@swatanabe-b1
Copy link
Contributor

The fix for this was released in 1.6.2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants