I'm trying to make a file in Ubuntu and when i make i keep getting this error:
/usr/bin/ld: ../../gtest-1.7.0/libgtest.a(gtest-all.cc.o): undefined reference to symbol 'pthread_key_delete##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/tests/run_tests] Error 1
make[1]: *** [src/tests/CMakeFiles/run_tests.dir/all] Error 2
make: *** [all] Error 2
I saw someone mentioning to go into Makefile and adding '-L /lib64 -l pthread' to the variable LDFLAGS but how do you do that? Totally new to linux here =X
The above linking problem is solved by adding
-lpthread -lm to CMakeLists.txt (target link libraries for luxrender);
TARGET_LINK_LIBRARIES(... -lpthread -lm)
I hit the same issue: -lpthread should be last in your linking invocation
(has to do with mix of static and shared symbols)
So with CMake: ${CMAKE_THREAD_LIBS_INIT} should be last. For example:
target_link_libraries(mytestlib
${BINARY_DIR}/libgmock.a
glog
gflags
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
And for the OP: Search for "thread" in the CMakeLists.txt for the project your are building and paste those section (or link which project you are trying to build if it is open source) - if the above isn't self explanatory
If you are building with Make or something else, add -pthread to the compilation command line (so GCC would generate thread-safe static locals) and to the linking command line (so GCC would tell the linker to do the right thing, most notably link with -lpthread).
If you are building with CMake - then most probably you need these (full example):
# always
FIND_PACKAGE(Threads REQUIRED)
# if using boost
SET(Boost_USE_MULTITHREADED ON)
TARGET_LINK_LIBRARIES(my_app ... ${CMAKE_THREAD_LIBS_INIT})
Related
I have no trouble building my application under Visual Studio's environment, but due to lack of experience, I am having trouble under Linux/GCC. Although GCC compiles my app successfully, but it reports linker errors.
The first thing I did was to build a shared library using CMakeLists.txt. The file has no ‘make install’ so I manually copied the shared library file to a global location as follows:
sudo cp libibpp.a /usr/local/lib/
Since applications built with the IBPP library require you to include a single header file, I copied it to a global location:
sudo cp ibpp.h /usr/local/include/
So far, so good but when I run CMake for my application, I am getting linker errors such as:
undefined reference to ‘isc_create_database’
I am successfully using many ‘shared libraries’ in my application (such as Boost Regex/Filesystem/Chrono/DateTime/Thread). The only ‘static library’ that I am using is IBPP (libibpp.a).
I suspect that I am missing something in my application’s CMakeListst.txt:
cmake_minimum_required(VERSION 3.10.2)
project(myapp)
file(GLOB src "*.h" "*.cpp")
add_executable(myapp ${src})
target_link_libraries(myapp ibpp icuuc icudata boost_regex boost_system boost_filesystem
boost_chrono boost_date_time boost_thread pthread)
add_definitions(-DIBPP_LINUX)
Can someone provide me with some hints as to why I get linker errors related to IBPP?
UPDATED:
User n.m. asked me to build using the VERBOSE option, so here is the output:
/usr/bin/cmake -E cmake_link_script CMakeFiles/myapp.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/myapp.dir/appServer.cpp.o CMakeFiles/myapp.dir/app_env.cpp.o CMakeFiles/myapp.dir/app_setting.cpp.o CMakeFiles/myapp.dir/authenticationServer.cpp.o CMakeFiles/myapp.dir/bustacheTestStencil.cpp.o CMakeFiles/myapp.dir/commonKeys.cpp.o CMakeFiles/myapp.dir/dataFetcher.cpp.o CMakeFiles/myapp.dir/fighterKeys.cpp.o CMakeFiles/myapp.dir/fighterProfileJsonGenerator.cpp.o CMakeFiles/myapp.dir/fighterProfileMarkupGenerator.cpp.o CMakeFiles/myapp.dir/fighterStorage.cpp.o CMakeFiles/myapp.dir/forwardProxyServer.cpp.o CMakeFiles/myapp.dir/headerProcessor.cpp.o CMakeFiles/myapp.dir/homepageStencil.cpp.o CMakeFiles/myapp.dir/httpUtils.cpp.o CMakeFiles/myapp.dir/locale.cpp.o CMakeFiles/myapp.dir/main.cpp.o CMakeFiles/myapp.dir/markupServer.cpp.o CMakeFiles/myapp.dir/myTools.cpp.o CMakeFiles/myapp.dir/stdafx.cpp.o CMakeFiles/myapp.dir/unicodeFunctions.cpp.o CMakeFiles/myapp.dir/utils.cpp.o -o myapp -libpp -licutu -licutest -licuio -licui18n -licuuc -licudata -lboost_regex -lboost_system -lboost_filesystem -lboost_chrono -lboost_date_time -lbustache -lboost_thread -lpthread
//usr/local/lib/libibpp.a(_ibpp.cpp.o): In function `ibpp_internals::GDS::Call()':
_ibpp.cpp:(.text+0x2c): undefined reference to `isc_create_database'
_ibpp.cpp:(.text+0x3b): undefined reference to `isc_attach_database'
....
_ibpp.cpp:(.text+0x2bd): undefined reference to `isc_service_start'
_ibpp.cpp:(.text+0x2cf): undefined reference to `isc_service_query'
collect2: error: ld returned 1 exit status
CMakeFiles/myapp.dir/build.make:640: recipe for target 'myapp' failed
make[2]: *** [myapp] Error 1
make[2]: Leaving directory '/home/carol/Documents/vm_shared/AppServer/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/myapp.dir/all' failed
make[1]: *** [CMakeFiles/myapp.dir/all] Error 2
make[1]: Leaving directory '/home/carol/Documents/vm_shared/AppServer/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Problem solved thanks to comment by n.m. above. Since I was not including libfbclient, I was getting the "undefined references to 'isc_create_database', and other 'isc_...' messages.
Using the settings below, I am now able to use my precompiled/built IBPP library instead of having to include the source code into my application!
Here is a simplified, very barebones CMakeLists.txt that demonstrates what is required to get your IBPP.a implemented into your app without having to include the IBPP source into your app:
file(GLOB src "*.cpp")
add_executable(myapp ${src})
target_link_libraries(myapp ibpp fbclient)
Make note of the order, libibpp must be before libfbclient.
I have python2.7.9 on my new Xubuntu installation, albeit it's 14.04.
PySide installation stuck with Shiboken
Linking CXX shared library libshiboken-python2.7.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libshiboken/libshiboken-python2.7.so.1.2.2] Error 1
make[1]: *** [libshiboken/CMakeFiles/libshiboken.dir/all] Error 2
make: *** [all] Error 2
error: Error compiling shiboken
After some "googling" I concluded that the problem could be solved with add --enable-shared at ./configure options.
Following docs tried to installed Shiboken in several ways, but after failed, tried to find configure in source files which I couldn't.
Please help. Thank you.
The output is showing that it's trying to link against a static python library, rather than a shared one - i.e. libpython2.7.a, rather than libpython2.7.so.
Thus, it's python that needs to be re-compiled with --enable-shared, not shiboken.
I am attempting to build the AR Drone SDK on Ubuntu. When compiling the libraries I get the error:
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I dont understand what the problem is. I am following this tutorial and the problem occurs when I run make. I have run ARDroneLib/Soft/Build/check_dependencies.sh and it outputs ok.
Any ideas what the problem is? Below is the full output from running make.
soribo#soribo-vm:~/Projects/ARDrone/ARDrone_SDK_2_0_1/Examples/Linux$ make
make[1]: Entering directory `/home/soribo/Projects/ARDrone/ARDrone_SDK_2_0_1/ARDroneLib/Soft/Build'
Libs already extracted
Building target static
Architecture x86_64 is already built
Creating universal static lib file from architectures x86_64
Build done.
Checking required Ubuntu packages ...
ok.
Building ARDroneTool/Lib
Building ARDroneTool/Lib
make[1]: Leaving directory `/home/soribo/Projects/ARDrone/ARDrone_SDK_2_0_1/ARDroneLib/Soft/Build'
make[1]: Entering directory `/home/soribo/Projects/ARDrone/ARDrone_SDK_2_0_1/Examples/Linux/Navigation/Build'
-- Building ardrone_navigation --
Libs already extracted
Building target static
Architecture x86_64 is already built
Creating universal static lib file from architectures x86_64
Build done.
Checking required Ubuntu packages ...
ok.
Building ARDroneTool/Lib
Building ARDroneTool/Lib
-- Linking ardrone_navigation --
ld common/mobile_main
/usr/bin/ld: ../../Soft/Build/targets_versions/ffmpeg_static_PROD_MODE_Linux_3.19.0-25-generic_GNU_Linux_usrbingcc_4.8.4/libavutil.a(eval.o): undefined reference to symbol 'fabs##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[4]: *** [/home/soribo/Projects/ARDrone/ARDrone_SDK_2_0_1/Examples/Linux/Navigation/Build/../../Build/Release/common/mobile_main] Error 1
make[3]: *** [all] Error 2
make[2]: *** [build_app] Error 2
make[1]: *** [ardrone_navigation] Error 2
make[1]: Leaving directory `/home/soribo/Projects/ARDrone/ARDrone_SDK_2_0_1/Examples/Linux/Navigation/Build'
make: *** [all] Error 2
I had the same problem. I found the solution here:
http://jderobot.org/Varribas-tfm/ARDrone:starting_up#Building_Examples
Looking for undefined reference to symbol 'fabs##GLIBC_2.2.5', I reached to [2], that confirms an unmeet dependency problem [1].
What happened here?
libavutil.a(eval.o): undefined reference to symbol 'fabs##GLIBC_2.2.5'
libm.so.6: error adding symbols: DSO missing from command line
First line say us that libavutil is using fabs. It is declared into libm library, but -lm is missed in command line (Makefile).
ARDrone_SDK_2_0_1/Examples/Linux/Navigation/Build/Makefile:131
GENERIC_LIBS+=-liw -lpc_ardrone -lgthread-2.0 -lgtk-x11-2.0 -lrt -lxml2 -ludev -lswscale -lSDL -lm
Then, Navigation will compile successfully.
I have installed boost along with other dependencies needed for Cassandra cpp driver on my ubuntu 12.04 LTS. When I try to run command below it ends up with two errors. I have looked for solutions but can't find any. Some say to link in the libboost_system by adding the option -lboost_system which I tried, but doesn't help.
Here is the cmd: cmake . && make && make cql_demo && make cql_test && make test && make install -lboost_system
All i want to do is to run the demo from the driver and to communicate with the cassandra database!
Errors:
-- info CMAKE_BINARY_DIR: /home/pi/experiments/cpp-driver-master2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/experiments/cpp-driver-master2
[ 42%] Built target cql
[ 85%] Built target cql_static
[ 87%] Built target CCMBridge
Linking CXX executable cql_integration_tests
/usr/bin/ld: warning: libboost_thread.so.1.55.0, needed by /usr/local/lib/libboost_log.so, may conflict with libboost_thread.so.1.46.1
/usr/bin/ld: CMakeFiles/cql_integration_tests.dir/src/test_utils.cpp.o: undefined reference to symbol 'boost::future_category()'
/usr/bin/ld: note: 'boost::future_category()' is defined in DSO /usr/local/lib/libboost_thread.so.1.55.0 so try adding it to the linker command line
/usr/local/lib/libboost_thread.so.1.55.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[2]: *** [test/integration_tests/cql_integration_tests] Error 1
make[1]: *** [test/integration_tests/CMakeFiles/cql_integration_tests.dir/all] Error 2
make: *** [all] Error 2
The following error:
/usr/bin/ld: warning: libboost_thread.so.1.55.0, needed by /usr/local/lib/libboost_log.so, may conflict with libboost_thread.so.1.46.1
is basically saying that you have two versions of Boost installed:
Custom built one in /usr/local/lib/, probably version 1.55.0.
Another one in system directories, probably version 1.46.1.
and when they both get linked to your binary version 1.46.1 wins.
You need to see all complete command lines that CMake invokes for you to tell exactly where the problem is.
I need your help about this problem if anyone has info.
I have configured speex1.2rc1 for xscale-elf (ARM architecture) ,then executed make and make install. So, I obtained libspeex.a in the /usr/local/lib with libogg.a compiled as well. but i when i link the library to my program (by adding LDFLAGS += -lspeex -lm), and try to compile, i get this error:
/usr/lib/gcc/xscale-elf/3.4.3/../../../../xscale-elf/bin/ld: cannot find -lspeex
collect2: ld returned 1 exit status
make: *** [exe0] Error 1
I passed ./configure options as :
./configure --host=xscale-elf
It's likely that the linker can't see libspeex.a, and I also tried the line LDFLAGS += /usr/local/lib/libspeex.a -lm in Makefile but got another error(also in linking):
/tmp/ccvi7Pns.o(.text+0x179c): In function `main':
: undefined reference to `BlinkC$speex_bits_init'
collect2: ld returned 1 exit status
make: *** [exe0] Error 1
./configure --host=xscale-elf
You didn't tell what host you are compiling this on, but given the path to your ld, it appears that you are cross-compiling. If so, your host is likely not xscale-elf (but probably i686-linux-gnu or some such).
You need to understand the difference between host and target, and rebuild your speex1 (whatever that is) using appropriate compiler and --target=xscale-elf.
Also, installing libraries intended for taget into /usr/local/lib is the wrong thing to do.