Question

I'm trying to cross-compile telldus-core to be able to use a Tellstick on my Synology NAS. I start by running Cmake with this command:

bengt@bengt-VirtualBox:/usr/local/src/telldus-core-2.1.1/build$ cmake -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabi-gcc-4.7 -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabi-g++-4.7 -DCMAKE_INSTALL_PREFIX=/opt -pthread ..

This leads to the following output:

-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  

Then running make results in:

[ 98%] Building CXX object tdtool/CMakeFiles/tdtool.dir/main.cpp.o
Linking CXX executable tdtool
/usr/local/src/telldus-core-2.1.1/build/client/libtelldus-core.so: undefined reference to `pthread_create'
/usr/local/src/telldus-core-2.1.1/build/client/libtelldus-core.so: undefined reference to `pthread_join'
collect2: fel: ld returnerade avslutningsstatus 1
make[2]: *** [tdtool/tdtool] Fel 1
make[1]: *** [tdtool/CMakeFiles/tdtool.dir/all] Fel 2
make: *** [all] Fel 2
bengt@bengt-VirtualBox:/usr/local/src/telldus-core-2.1.1/build$ 

What should I do to solve this?

Was it helpful?

Solution

Gak! Why are you running cmake under sudo?!?! The horror.

This error is because you haven't added -lpthread (the POSIX thread library) to your link line. I don't think adding -pthread to the end of the cmake command line will do that. You'll need to modify the CMakeLists.txt file and ensure the flag is present on both the compilation and link lines.

Or I guess you could try to do it like this:

cmake -DCMAKE_C_COMPILER='/usr/bin/arm-linux-gnueabi-gcc-4.7 -pthread' \
    -DCMAKE_CXX_COMPILER='/usr/bin/arm-linux-gnueabi-g++-4.7 -pthread' \
    -DCMAKE_INSTALL_PREFIX=/opt ...

OTHER TIPS

Managed to make it compile with following lines added to /CMakeFiles.txt /tdtool/CMakeFiles.txt and /tdadmin/CMakeFiles.txt

SET(FORCE_COMPILE_FROM_TRUNK TRUE)
SET(GCC_COVERAGE_COMPILE_FLAGS "-Wno-narrowing")
SET(GCC_COVERAGE_LINK_FLAGS "-pthread -lpthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top