Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: build errors  (Read 916 times)

0 Members and 1 Guest are viewing this topic.

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
build errors
« 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'

Offline speedy

  • Hero Member
  • *****
  • Posts: 1160
    • View Profile
  • BTS: speedy
Re: build errors
« Reply #1 on: February 13, 2014, 11:52:06 PM »
Inside /bts_wallet/CMakeLists.txt (or whichever app you are building), you need to add pthread as an argument to target_link_libraries().

Offline bytemaster

Re: build errors
« Reply #2 on: February 14, 2014, 01:21:35 AM »
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.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #3 on: February 14, 2014, 01:28:46 AM »
I tried both pthread and ${pthread} and got the same problem each time.

Offline bytemaster

Re: build errors
« Reply #4 on: February 14, 2014, 01:50:56 AM »
I tried both pthread and ${pthread} and got the same problem each time.

Which executable are you attempting to build?
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #5 on: February 14, 2014, 02:02:56 AM »
bts_server and bts_wallet

Offline bytemaster

Re: build errors
« Reply #6 on: February 14, 2014, 02:15:47 AM »
bts_server and bts_wallet

Link order matters in linux... try putting it at the beginning and end of the lib list.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #7 on: February 14, 2014, 03:07:56 AM »
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

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #8 on: February 14, 2014, 03:18:58 AM »
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'

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #9 on: February 14, 2014, 03:28:47 AM »
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)

Offline bytemaster

Re: build errors
« Reply #10 on: February 14, 2014, 03:29:32 AM »
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.
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #11 on: February 14, 2014, 03:55:52 AM »
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?

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #12 on: February 14, 2014, 04:00:08 AM »
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

Offline alt

Re: build errors
« Reply #13 on: February 14, 2014, 05:18:24 AM »
I add it at fc/CMakeLists.txt
Code: [Select]
-target_link_libraries( fc easylzma_static ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} )
+target_link_libraries( fc easylzma_static ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} )
 

Offline HardFork

  • Jr. Member
  • **
  • Posts: 26
    • View Profile
Re: build errors
« Reply #14 on: February 14, 2014, 12:48:58 PM »
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)

 

Google+