make error: phtread

Moderator: Telldus

Post Reply
bengan
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

make error: phtread

Post by bengan »

Hi!

I get this error running make:

Code: Select all

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
How do I correct this? Note that I'm cross-compiling telldus-center for the arm architecture (Synology NAS) on a Xubuntu PC.

Regards,
Bengt
bengan
Posts: 3
Joined: Fri Mar 17, 2023 9:45 am

Re: make error: phtread

Post by bengan »

Answering my own question:

I put the following lines in the CMakeLists.txt file:

Code: Select all

set(CMAKE_C_FLAGS "-pthread")
set(CMAKE_CXX_FLAGS "-pthread")
oden
Posts: 7
Joined: Fri Mar 17, 2023 9:45 am

Re: make error: phtread

Post by oden »

This is a linking ordering problem commonly seen when using -Wl,--no-undefined. This is the fix:

--- client/CMakeLists.txt 2014-02-14 10:26:19.000000000 +0100
+++ client/CMakeLists.txt.oden 2014-03-31 11:31:44.524436965 +0200
@@ -21,8 +21,6 @@
telldus-core.h
)

-FIND_PACKAGE(Threads)
-LIST(APPEND telldus-core_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})

@@ -100,6 +98,9 @@

ADD_DEPENDENCIES(${telldus-core_TARGET} TelldusCommon)

+FIND_PACKAGE(Threads)
+LIST(APPEND telldus-core_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+
IF (UNIX)
SET_TARGET_PROPERTIES( ${telldus-core_TARGET} PROPERTIES COMPILE_FLAGS "-fPIC -fvisibility=hidden")
ENDIF (UNIX)
Post Reply