11

First off, please keep in mind that I'm new to linux. I'm having problems compiling my project. I keep get the following error:

/usr/bin/ld: CMakeFiles/Robot.dir/source/ModuleHandler.cpp.o: undefined reference to symbol 'dlsym@@GLIBC_2.4' //lib/arm-linux-gnueabihf/libdl.so.2: error adding symbols: DSO missing from command line collect2: ld returned 1 exit status

First off the correct directory is: /usr/lib/arm-linux-gnueabihf/libdl.so Rather than: //lib/arm-linux-gnueabihf/libdl.so

I've tried updating my ldconfig.conf file, setting LD_LIBRARY_PATH, using ldd -r to no avail.

CMAKE is used to create the make file.

I've previously had no problems compiling. It started either when I did a apt-get upgrade or after a tried cross-compiling from VS.

Any suggestions would be greatly appreciated!

//Nathan

Raydel Miranda
  • 13,825
  • 3
  • 38
  • 60
Nathan
  • 135
  • 1
  • 2
  • 9
  • Is expected that you're trying to link your program against an ARM-specific library? – user3159253 Apr 10 '15 at 09:24
  • No idea. Assuming it is however...? – Nathan Apr 10 '15 at 09:56
  • Well, likely it's a mistake. Normally if you have a x86 compatible workstation, you should use an "ordinary" compiler which doesn't try to use libraries for cross-compiling. What hardware and linux distributions do you use? – user3159253 Apr 10 '15 at 10:32
  • Thanks. I resolved the problem by adding: SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ldl -lpthread") – Nathan Apr 10 '15 at 10:40
  • 1
    Thanks. I resolved the problem by adding: SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ldl -lpthread") to the CMakeLists.txt file. But if you're interested. I've been "normally" compiling my project remotely on my Raspberry Pi (running Raspbian Wheezy). However I've been coding in Visual Studio, copying source files to The Pi and then compiling. Not very effecient. Therefore I tried using VisualGDB to build and that's most likely when the problem ensued. Nevertheless thanks again! – Nathan Apr 10 '15 at 10:48

3 Answers3

28

In general, the man page for the symbol you can't find tells you what libraries you need to link in. In your case:

http://linux.die.net/man/3/dlsym

Note the line:

Link with -ldl.

Andrew Henle
  • 32,625
  • 3
  • 24
  • 56
0

For me reinstalling libglfw3-dev worked (sudo apt install libglfw3-dev). I suspect this had been removed during an update.

0

I switched to clang. That fixed my problem

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
cmake ..
Mohammad f
  • 961
  • 10
  • 11