BitShares Forum
Main => Technical Support => Topic started by: HardFork on February 13, 2014, 10:19:28 pm
-
I followed the build instructions.
When I run: make
I get:
../vendor/leveldb-1.12.0/libleveldb.a(port_posix.cc.o): In function `leveldb::port::InitOnce(int*, void (*)())':
/home/tzadik/BitShares/vendor/leveldb-1.12.0/port/port_posix.cc:50: undefined reference to `pthread_once'
-
Inside /bts_wallet/CMakeLists.txt (or whichever app you are building), you need to add pthread as an argument to target_link_libraries().
-
Inside /bts_wallet/CMakeLists.txt (or whichever app you are building), you need to add pthread as an argument to target_link_libraries().
Don't just add pthread, use ${pthread} which is conditionally set on Linux.... submit a pull request and I will merge it.
-
I tried both pthread and ${pthread} and got the same problem each time.
-
I tried both pthread and ${pthread} and got the same problem each time.
Which executable are you attempting to build?
-
bts_server and bts_wallet
-
bts_server and bts_wallet
Link order matters in linux... try putting it at the beginning and end of the lib list.
-
I tried both beginning and ending and i'm still getting the same problem.
I also ran: make VERBOSE=1 to capture the command that caused the errors:
/usr/bin/c++ -O2 -g -DNDEBUG CMakeFiles/bts_server.dir/server.cpp.o CMakeFiles/bts_server.dir/chain_connection.cpp.o CMakeFiles/bts_server.dir/chain_server.cpp.o -o bts_server -rdynamic ../libbshare.a -lrt -ldl ../fc/libfc.a ../fc/vendor/easylzma/src/libeasylzma_static.a -Wl,-Bstatic -lboost_thread-mt -lboost_date_time-mt -lboost_system-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_signals-mt -lboost_serialization-mt -lboost_chrono-mt -lboost_unit_test_framework-mt -lboost_context-mt -lboost_coroutine -lssl -lcrypto ../vendor/miniupnp/miniupnpc/libminiupnpc.a ../vendor/leveldb-1.12.0/libleveldb.a -Wl,-Bdynamic -ldb_cxx -lz
but the command doesn't even have -lpthread in it, so it doesn't seem like my changing the CMakeLists.txt had any effect. I even tried adding -lpthread to the command manually (both at the beginning and end) and that didn't help... still the same error
-
OK, I finally got past it by using pthread (not ${pthread})
Now I have a new error:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x11): undefined reference to `dlopen'
-
OK... I had previously added pthread to several CMakeLists.txt files but I wanted to narrow it down, so I removed them all and added them back one by one.
It turns out the only change needed to get past the "undefined reference to `pthread_once'" error was to add the line:
target_link_libraries( leveldb pthread )
to the end of "BitShares/vendor/leveldb-1.12.0/CMakeLists.txt"
(Previously there was no target_link_libraries at all in that file)
-
OK, I finally got past it by using pthread (not ${pthread})
Now I have a new error:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
(.text+0x11): undefined reference to `dlopen'
Add "dl" after pthread.
-
I already figured out to try that and it didn't work. (It turns out dl was already there anyway because of ${CMAKE_DL_LIBS} so me adding dl just caused it to appear twice)
I ran: make VERBOSE=1 to find out the command that was failing and if I manually run that /usr/bin/c++ command, adding -ldl at the very end, it succeeds. So how can we get CMakeLists.txt put dl at the very end of the /usr/bin/c++ command?
-
Here is the command I ran manually which succeeded:
/usr/bin/c++ -O2 -g -DNDEBUG CMakeFiles/bts_wallet.dir/main.cpp.o CMakeFiles/bts_wallet.dir/chain_connection.cpp.o -o bts_wallet -rdynamic ../libbshare.a -lrt -lreadline -ldl ../fc/libfc.a ../fc/vendor/easylzma/src/libeasylzma_static.a -Wl,-Bstatic -lboost_thread-mt -lboost_date_time-mt -lboost_system-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_signals-mt -lboost_serialization-mt -lboost_chrono-mt -lboost_unit_test_framework-mt -lboost_context-mt -lboost_coroutine -lssl -lcrypto ../vendor/miniupnp/miniupnpc/libminiupnpc.a ../vendor/leveldb-1.12.0/libleveldb.a -Wl,-Bdynamic -lpthread -ldb_cxx -lz -ldl
Note that there is an "-ldl" early in the command (presumably from the ${CMAKE_DL_LIBS} in CMakeLists.txt) and that I had to add "-ldl" again at the end.
Need to get this to happen using only CMakeLists.txt
-
I add it at fc/CMakeLists.txt
-target_link_libraries( fc easylzma_static ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} )
+target_link_libraries( fc easylzma_static ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} )
-
That doesn't help... my target_link_libraries already has ${CMAKE_DL_LIBS} ... it still fails because -ldl needs to be last in the c++ command line (see my previous post)
-
That doesn't help... my target_link_libraries already has ${CMAKE_DL_LIBS} ... it still fails because -ldl needs to be last in the c++ command line (see my previous post)
try this:
diff Bitshares/CMakeLists.txt
--target_link_libraries(bshare fc upnpc-static leveldb ${BDB_LIBRARIES} ${ZLIB_LIBRARIES})
++target_link_libraries(bshare fc upnpc-static leveldb ${BDB_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS})
-
It worked! Rock on!