EOSIO/eosio.contracts

Unable to build tests

jacojoubert12 opened this issue · 19 comments

Does anyone perhaps know which dependencies are missing or what prerequisites there are to build the tests?

I am running into a bunch of 'undeclared identifier' errors as shown below. I am also not sure where 'N' is defined and what it does as I can't find anything about it.

error: reference to non-static member function must be called; did you mean to call it with no arguments?
         base_tester::push_action(config::system_account_name, N(init),

error: use of undeclared                                                                                                               
      identifier 'carol'                                                                                                                                                                                   
  ...N(prod1), N(prod2), N(prod3), N(prod4), N(prod5), N(alice), N(bob), N(carol) } );

error: unexpected namespace
      name 'eosio': expected expression
      set_abi( N(eosio.token), contracts::token_abi().data() );

N(alice1111111)
error: use of undeclared identifier 'alice1111111'

etc.

In other repos, "alice1111111" is used as a string. It is not clear, for example, what data type it is supposed to be here.

Any help or advice on this will be much appreciated.

deckb commented

Those errors are usually because the wrong version EOSIO is being used. For the latest contract release EOSIO 2.0.x is required to build the tests.

Thank you. The current EOSIO that is built from source using instructions given on the EOSIO website is 2.1. The CMakeLists.txt file was adjusted to use 2.1 and not 2.0. Is there a specific header file where these can be found for closer inspection, or perhaps a directory to add to a path/library variable that might help?

==============================================================================================
EOSIO has been installed into /root/eosio/2.1/bin                                             
Uninstall with: /root/eosio/eos/scripts/eosio_uninstall.sh                                    
==============================================================================================                                                                                           
~/eosio/eos# nodeos --version
v2.1.0

Although it does seem like there are less issues after re-installing EOSIO. I don't see the allice111111 errors where it is not used as a string ("allice111111"), but it still complains about the N(...)
Output attached:

build_out.txt

deckb commented

I believe the N macro was removed in eosio 2.1 and that is why I mentioned that you need to build eosio 2.0.x (https://github.com/EOSIO/eos/tree/v2.0.12) for the latest version of eosio.contracts.

Thank you for the specific link. I will build that one.

With your help, I made some progress. It now seems like there is a compiler flag or something needed. Do you perhaps have any insight on how to get past this? This is on Ubuntu 18.0.4

/usr/bin/ld: /root/eosio/2.0/lib/libfc.a(logger_config.cpp.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'                                                                              
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line                                                                                                                
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)                                                                                                                          
CMakeFiles/unit_test.dir/build.make:244: recipe for target 'unit_test' failed                                                                                                                              
make[2]: *** [unit_test] Error 1                                                                                              
CMakeFiles/Makefile2:111: recipe for target 'CMakeFiles/unit_test.dir/all' failed                                                                                                                          
make[1]: *** [CMakeFiles/unit_test.dir/all] Error 2                                                                                                        
Makefile:100: recipe for target 'all' failed                                                                                                                                                               
make: *** [all] Error 2                                                                                                                                                                                    

Adding

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

to the tests' CMakeLists.txt made the error go away, but caused a lot of other errors from EOSIO.

I noticed this issue:
EOSIO/eos#7490

It does not seem like the 'pthread' flag was added to the repo.

It is not clear if I am on the right path with this.

deckb commented

Did you build eosio or did you just install it?

I built it from the source you sent (checked out the commit in your link). It built 2.0 and then I installed it with the command provided after the build.

I also rebuilt it after adding the pthread flag as mentioned in issue #7490 that I referred to above.

deckb commented

Couple of additional questions:

What OS are you on?
What is the command you used to build EOSIO?
What version of BOOST was installed?
If you installed EOSIO using a deb did you uninstall it?
what is the output of the command which nodeos

Couple of additional questions:

What OS are you on?
What is the command you used to build EOSIO?
What version of BOOST was installed?
If you installed EOSIO using a deb did you uninstall it?
what is the output of the command which nodeos

Ubuntu 18.04
./scripts/eosio_build.sh -P
boost_1_72_0
Yes it was uninstalled previously

which nodeos
/usr/local/bin/nodeos

(I copied the eos/bin/* to /usr/local/bin/

deckb commented

Well there is something off with the build environment for sure. Any chance you have the log of the command ./scripts/eosio_build.sh -P?

You should be able to call the build script for eosio and then build the tests without modifying cmake files.

deckb commented

Before you built 2.0.12 did you call git submodule update --init --recursive? It is possible the submodule fc wasn't pulled in correctly since the pthread dependency for eosio is fulfilled by the fc submodule.

Yes, all submodules are updated. The build script warns if that wasn't done. What version of GCC is recommended?

Just to confirm, I made a clean clone of both eosio, and eosio.contracts and didn't make any changes to any file, script, or makefile.

I checked out 32a47e396a13b948263b1dc9762a6e2292a2c2ef on eosio, and it built successfully and I installed it using the install script provided.

I then built eosio.contracts using build.sh, and it built successfully.
Building the tests it using build.sh -t got me back to this output:

/usr/bin/ld: /root/eosio/2.0/lib/libfc.a(logger_config.cpp.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/unit_test.dir/build.make:244: recipe for target 'unit_test' failed
make[5]: *** [unit_test] Error 1
CMakeFiles/Makefile2:111: recipe for target 'CMakeFiles/unit_test.dir/all' failed
make[4]: *** [CMakeFiles/unit_test.dir/all] Error 2
Makefile:100: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/contracts_unit_tests.dir/build.make:86: recipe for target 'contracts_unit_tests-prefix/src/contracts_unit_tests-stamp/contracts_unit_tests-build' failed
make[2]: *** [contracts_unit_tests-prefix/src/contracts_unit_tests-stamp/contracts_unit_tests-build] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/contracts_unit_tests.dir/all' failed
make[1]: *** [CMakeFiles/contracts_unit_tests.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 95%] Linking CXX executable eosio.system.wasm
[100%] Built target eosio.system
[ 44%] No install step for 'contracts_project'
[ 50%] No test step for 'contracts_project'
[ 55%] Completed 'contracts_project'
[ 83%] Built target contracts_project
Makefile:90: recipe for target 'all' failed

It started building successfully. Unfortunately, I'm not exactly sure what caused the fix. Amongst other things and trying things over and over, I also installed gcc-8 g++-8 and clang-8, but I'm not sure if this made the difference.

https://gist.github.com/orenyomtov/7dc59d121d8405f710711e6008cfa1bb

deckb commented

I also installed gcc-8 g++-8 and clang-8, but I'm not sure if this made the difference.

That is likely the fix. Closing this for now. Please re-open if additional issues crop up.