Ask Your Question
0

Catkin_make_isolated pthread linking error

asked 2013-09-22 05:29:21 -0500

St3am gravatar image

updated 2014-01-28 17:18:02 -0500

ngrennan gravatar image

I'm running a fresh install of Debian Wheezy and trying to install ROS hydro from source and am on the following step:

./src/catkin/bin/catkin_make_isolated --install

My build dies 3/4 of the way through, but for a different error than the one in this question. Trying to solve this other issue I became curious about one of the common cmake errors I get in the CMakeError.log's:

$ find . -type f -exec grep "cannot find" {} +
...
./build_isolated/tf2_bullet/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/rqt_web/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/rqt_plot/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/robot/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/angles/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/pcl_conversions/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/smach_ros/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/rqt_srv/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/catkin/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/random_numbers/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/trajectory_msgs/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/rosmaster/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/eigen_conversions/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/geometric_shapes/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
./build_isolated/collada_parser/CMakeFiles/CMakeError.log:/usr/bin/ld: cannot find -lpthreads
... and hundreds more

The full error from ./build_isolated/rosmaster/CMakeFiles/CMakeError.log looks like:

$cat ./build_isolated/rosmaster/CMakeFiles/CMakeError.log
...
/usr/bin/gcc         CMakeFiles/cmTryCompileExec1355085001.dir/CheckSymbolExists.c.o  -o cmTryCompileExec1355085001 -rdynamic 
CMakeFiles/cmTryCompileExec1355085001.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec1355085001] Error 1
make[1]: Leaving directory `/home/nexix/Documents/source/ros_catkin_ws/build_isolated/rosmaster/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec1355085001/fast] Error 2
...
/usr/bin/gcc     -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTryCompileExec2282391930.dir/CheckFunctionExists.c.o  -o cmTryCompileExec2282391930 -rdynamic -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [cmTryCompileExec2282391930] Error 1
make[1]: Leaving directory `/home/nexix/Documents/source/ros_catkin_ws/build_isolated/rosmaster/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec2282391930/fast] Error 2

I have pthread installed, but the spelling is slightly different:

$ locate libpthread
/lib/x86_64-linux-gnu/libpthread-2.13.so
/lib/x86_64-linux-gnu/libpthread.so.0
/usr/lib/x86_64-linux-gnu/libpthread.a
/usr/lib/x86_64-linux-gnu/libpthread.so
/usr/lib/x86_64-linux-gnu/libpthread_nonshared.a

But looking in the CMakeCache file makes it look like the logic is there to get around naming differences like that:

$ cat ./build_isolated/rosmaster/CMakeCache.txt
...
gtest_LIB_DEPENDS:STATIC=general;-lpthread;
...
//Disable uses of pthreads in gtest.
gtest_disable_pthreads:BOOL=OFF
...
//Dependencies for the target
gtest_main_LIB_DEPENDS:STATIC=general;-lpthread;general;gtest;
...
//Have symbol pthread_create
CMAKE_HAVE_LIBC_CREATE:INTERNAL=
//Have library pthreads
CMAKE_HAVE_PTHREADS_CREATE:INTERNAL=
//Have library pthread
CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1
//Have include pthread.h
CMAKE_HAVE_PTHREAD_H:INTERNAL=1
...

My question is how do I find out if this is causing compile problems? It seems to be ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-09-28 21:07:30 -0500

tfoote gravatar image

That error is being thrown by a try compile block which is designed to detect if the symbol exists. This is how CMake detects if the library is available. It simply tries to compile a small snippet of code which requires the library. From your config it detects that pthreads_create is not present, but it shows that pthread_create does exist. So it's not actually a compile error that you're seeing.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-09-22 05:29:21 -0500

Seen: 3,374 times

Last updated: Sep 28 '13