Having a libpthread.so linking trouble on Ubuntu
Solution 1
try reconfiguring with pthread included like so:
$ CFLAGS='-lpthread' ./configure
Solution 2
In the TARGET_LINK_LIBRARIES
command, move pthread
so it is the last item. The GNU linker requires dependent libraries to come before their dependencies.
You should not have to specify any absolute path to the pthread libraries like you are currently doing in CMAKE_CXX_FLAGS_DISTRIBUTION
, and doing so limits the portability of the project.
Solution 3
You need to link to X11 and pthread, I've had this problem before with glfw.
-lX11 -lpthread
Admin
Updated on June 05, 2022Comments
-
Admin almost 2 years
I've downloaded source code from this site http://mnbayazit.com/406/bayazit
This project has some dependencies:
Libraries: FTGL (for fonts), FreeType2 (needed by FTGL), GLFW (for windows and keyboard input), OpenGL. Software: CMake (if it doesn't build) But I'm having a problem with it.
And installation guide looks like
To build and run:
cmake . make ./conv
and I am trying to build it.
$ cmake .
goes just fine, but when I'm trying to
$ make
I get this error:
Linking CXX executable conv /usr/bin/ld: /usr/local/lib/libglfw.a(x11_init.o): undefined reference to symbol 'pthread_kill@@GLIBC_2.0' /usr/bin/ld: note: 'pthread_kill@@GLIBC_2.0' is defined in DSO /lib/i386-linux-gnu/libpthread.so.0 so try adding it to the linker command line /lib/i386-linux-gnu/libpthread.so.0: could not read symbols: Invalid operation collect2: ld returned 1 exit status make[2]: *** [conv] Error 1 make[1]: *** [CMakeFiles/conv.dir/all] Error 2 make: *** [all] Error 2
I googled this problem and I tried to change CMakeLists.txt by changing
SET(CMAKE_BUILD_TYPE distribution) SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3")
to
SET(CMAKE_BUILD_TYPE distribution) SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3 -L/usr/lib/i386-linux-gnu/lpthread")
But nothing changed. I googled hardly for a couple of hours, but I can't really solve the problem, I'm still having the same error. By the way,
TARGET_LINK_LIBRARIES(conv Xrandr pthread ftgl glfw ${OPENGL_LIBRARIES})
I suppose, I needn't change anything in this string?
P.S. I'm using ubuntu 11.10 if that means something :)