Having a libpthread.so linking trouble on Ubuntu
Asked Answered
G

4

6

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 :)

Guyton answered 19/11, 2011 at 23:9 Comment(1)
Just a shot in the dark, try TARGET_LINK_LIBRARIES(conv Xrandr pthread ftgl glfw ${OPENGL_LIBRARIES} pthread)Picasso
Y
8

try reconfiguring with pthread included like so:

$ CFLAGS='-lpthread' ./configure
Yeisk answered 10/6, 2013 at 9:5 Comment(1)
I needed to use this for installing Barnyard2 on Ubuntu 13.04, after a couple of hours struggling. Lets hope google finds this comment for any others having the issue.Ophthalmologist
P
1

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.

Placid answered 4/12, 2011 at 16:18 Comment(0)
L
1

You need to link to X11 and pthread, I've had this problem before with glfw.
-lX11 -lpthread

Lisandra answered 18/1, 2012 at 7:18 Comment(0)
D
0

Setting -L to a file basename won't solve any problems. If anything, you should set:

SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3 -L/usr/lib/i386-linux-gnu/")

to include the multi-arch lib directory. However, the compiler should do this on its own if you have an up-to-date version of the Ubuntu-shipped compiler.

Dipstick answered 20/11, 2011 at 17:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.