cmake + g++ fail linking winsock2.h library [duplicate] - c++

This question already has answers here:
How to add "-l" (ell) compiler flag in CMake
(2 answers)
How to set library flags after source file in cmake?
(1 answer)
Closed 2 years ago.
I have cmake 3.17.1 , g++ 9.2.0. Trying to build my project :
cmake_minimum_required(VERSION 3.17.1)
project("Client")
SET( CMAKE_MAKE_PROGRAM C:/Strawberry/c/bin/mingw32-make.exe FORCE )
set(CMAKE_CXX_FLAGS "-std=c++17 -lwsock32 -lws2_32" )
add_executable(Client
main.cpp
client.cpp
client.h
logmsg.cpp
includes.h
)
it compiles but linking fails with errors:
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x144): undefined reference to `__imp_WSAStartup'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x270): undefined reference to `__imp_inet_addr'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x28b): undefined reference to `__imp_htons'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x504): undefined reference to `__imp_socket'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x540): undefined reference to `__imp_connect'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x57d): undefined reference to `__imp_WSAGetLastError'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x7ac): undefined reference to `__imp_recv'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x895): undefined reference to `__imp_WSAGetLastError'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xbdd): undefined reference to `__imp_send'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xc02): undefined reference to `__imp_WSAGetLastError'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xcc6): undefined reference to `__imp_send'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xce4): undefined reference to `__imp_WSAGetLastError'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xe2e): undefined reference to `__imp_send'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xe4c): undefined reference to `__imp_WSAGetLastError'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xfb2): undefined reference to `__imp_send'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0xfd0): undefined reference to `__imp_WSAGetLastError'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x113c): undefined reference to `__imp_shutdown'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x1153): undefined reference to `__imp_closesocket'
CMakeFiles\Client.dir/objects.a(client.cpp.obj):client.cpp:(.text+0x115c): undefined reference to `__imp_WSACleanup'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles\Client.dir\build.make:135: Client.exe] Error 1
make[1]: *** [CMakeFiles\Makefile2:95: CMakeFiles/Client.dir/all] Error 2
make: *** [makefile:103: all] Error 2
Placed screenshoot also here: https://imgur.com/a/SFvYSfm .
I cannot understand why
-lwsock32 -lws2_32
flags do not solve it. What am i doing wrong?

Related

MinGW/CMake Undefined Reference to ZLib

I have a project I want to build with CMake and compile with MinGW. The project uses Zlib. When I build with CMake I get no errors but then when I run MinGW Make it gives the following output:
C:\Projects\MultiMCBuild>C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe
.
.
.
[ 50%] Linking CXX shared library ..\libMultiMC_logic.dll
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x1f6c): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x29e2): undefined reference to 'z_inflateInit2_'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2a6d): undefined reference to 'z_get_crc_table'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2ca7): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2f52): undefined reference to 'z_inflateInit2_'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x2f77): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3239): undefined reference to 'z_inflateInit2_'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3317): undefined reference to 'z_inflateEnd'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3626): undefined reference to 'z_crc32'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x371f): undefined reference to 'z_inflate'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x376a): undefined reference to 'z_crc32'
C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj):unzip.c:(.text+0x3a57): undefined reference to 'z_inflateEnd'
C:/Qt/Tools/mingw492_32/bin/../lib/gcc/i686-w64- mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: C:/Projects/MultiMCBuild/External/Install/QuaZIP/lib/libquazip.a(unzip.c.obj): bad reloc address 0x20 in section `.eh_frame'
collect2.exe: error: ld returned 1 exit status
logic\CMakeFiles\MultiMC_logic.dir\build.make:3186: recipe for target 'libMultiMC_logic.dll' failed
mingw32-make[2]: * * * [libMultiMC_logic.dll] Error 1
CMakeFiles\Makefile2:1806: recipe for target 'logic/CMakeFiles/MultiMC_logic.dir/all' failed
mingw32-make[1]: * * * [logic/CMakeFiles/MultiMC_logic.dir/all] Error 2
makefile:159: recipe for target 'all' failed
mingw32-make: * * * [all] Error 2
Anyone have a clue what I can do to fix this? I read that the code can't find the ZLib library, how do I link it?
EDIT here is my CMakeLists.txt. I got this from the Git project.
I just tried to generate a small example to reproduce your errors. I took my test file from the home page of zlib http://zlib.net/zpipe.c
My initial CMakeLists.txt was
cmake_minimum_required(VERSION 3.4)
project(zlib_test)
set(ZLIB_TEST_SOURCES zpipe.c)
add_executable(${PROJECT_NAME} ${ZLIB_TEST_SOURCES})
And I got the same errors
[ 50%] Building C object CMakeFiles/zlib_test.dir/zpipe.c.o
[100%] Linking C executable zlib_test
CMakeFiles/zlib_test.dir/zpipe.c.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xcd): undefined reference to `deflateEnd'
zpipe.c:(.text+0x135): undefined reference to `deflate'
zpipe.c:(.text+0x1cf): undefined reference to `deflateEnd'
zpipe.c:(.text+0x25d): undefined reference to `deflateEnd'
CMakeFiles/zlib_test.dir/zpipe.c.o: In function `inf':
zpipe.c:(.text+0x2eb): undefined reference to `inflateInit_'
zpipe.c:(.text+0x353): undefined reference to `inflateEnd'
zpipe.c:(.text+0x3a4): undefined reference to `inflate'
zpipe.c:(.text+0x404): undefined reference to `inflateEnd'
zpipe.c:(.text+0x476): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4a6): undefined reference to `inflateEnd'
collect2: error: ld returned 1 exit status
make[2]: *** [zlib_test] Error 1
make[1]: *** [CMakeFiles/zlib_test.dir/all] Error 2
make: *** [all] Error 2
After changing CMakeLists.txt to this form
cmake_minimum_required(VERSION 3.4)
project(zlib_test)
find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
set(ZLIB_TEST_SOURCES zpipe.c)
add_executable(${PROJECT_NAME} ${ZLIB_TEST_SOURCES})
target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES})
I could compile the program.
So your problem is: Where is ZLIB added in your CMakeLists.txt? At least, you need the line find_package(ZLIB REQUIRED).

CMake linker not working correctly

I am trying to build my project using CMake but I am having error linking required libraries. I have this CMakeLists.txt in the root folder of my project:
cmake_minimum_required(VERSION 2.6)
project(test)
add_subdirectory(src)
And in my src folder, alongside my source files I have this CMakeLists.txt:
set (CMAKE_CXX_FLAGS "Wall -std=c++11" )
set (CMAKE_EXE_LINKER_FLAGS "-lSDL2 -lGL" )
file (GLOB SRCS *.cpp *.h )
add_executable(engine ${SRCS} )
I then go into the build folder and do cmake .. and it runs without any errors. When I do make, the compilation runs without any errors as well, but when it gets to the linking part, I get these errors:
CMakeFiles/test.dir/Application.cpp.o: In function `Application::onExecute()':
Application.cpp:(.text+0x41): undefined reference to `SDL_GetTicks'
Application.cpp:(.text+0x4e): undefined reference to `SDL_GetTicks'
Application.cpp:(.text+0xd7): undefined reference to `SDL_PollEvent'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::render()':
Application.cpp:(.text+0x17b): undefined reference to `glClearColor'
Application.cpp:(.text+0x185): undefined reference to `glClear'
Application.cpp:(.text+0x194): undefined reference to `SDL_GL_SwapWindow'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::cleanUp()':
Application.cpp:(.text+0x1b2): undefined reference to `SDL_GL_DeleteContext'
Application.cpp:(.text+0x1c1): undefined reference to `SDL_DestroyWindow'
Application.cpp:(.text+0x1c6): undefined reference to `SDL_Quit'
CMakeFiles/test.dir/Application.cpp.o: In function `Application::initialize()':
Application.cpp:(.text+0x1de): undefined reference to `SDL_Init'
Application.cpp:(.text+0x1ea): undefined reference to `SDL_GetError'
Application.cpp:(.text+0x22b): undefined reference to `SDL_CreateWindow'
Application.cpp:(.text+0x243): undefined reference to `SDL_GetError'
Application.cpp:(.text+0x25a): undefined reference to `SDL_Quit'
Application.cpp:(.text+0x270): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x27f): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x28e): undefined reference to `SDL_GL_SetAttribute'
Application.cpp:(.text+0x29d): undefined reference to `SDL_GL_CreateContext'
Application.cpp:(.text+0x2af): undefined reference to `glGetString'
collect2: error: ld returned 1 exit status
make[2]: *** [src/test] Error 1
make[1]: *** [src/CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
I have the correct includes in my header files and I was able to compile and run using only make so I think the linker flags I tell CMake aren't being passed to the compiler. How can I fix this?
You have to use the cmake command target_link_libraries to reference SDL libs.

Compiling libmodbus in Qt Creator on Windows throws undefined reference to '_imp_....' errors

I have the source .h and .c files for libmodbus (http://libmodbus.org/releases/libmodbus-3.0.6.tar.gz). I dumped them into my Qt Project after learning that Qt is smart enough to know the difference b/w c and c++ files.
I include modbus.h in main.cpp and I get about 50 errors (most of which are undefined reference errors). Note I did get libmodbus working in ubuntu using codeblocks and it was communicating fine. I'm trying this in windows now and both Qt and codeblocks seem to be angry at me.
Here is my .pro file.
QT += core
QT += widgets
QT -= gui
TARGET = testModBus
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
QMAKE_CXXFLAGS += -w
QMAKE_CFLAGS += -w
SOURCES += main.cpp \
modbus.c \
modbus-data.c \
modbus-rtu.c \
modbus-tcp.c
HEADERS += \
config.h \
modbus.h \
modbus-private.h \
modbus-rtu.h \
modbus-rtu-private.h \
modbus-tcp.h \
modbus-tcp-private.h \
modbus-version.h \
zModBus.h \
inttypes.h \
stdint.h
And here is my Qt Output when I try to Compile:
18:03:02: Starting: "E:\Qt\Tools\mingw48_32\bin\mingw32-make.exe"
E:\Qt\5.2.1\mingw48_32\bin\qmake.exe -spec win32-g++ -o Makefile ..\testModBus\testModBus.pro
E:/Qt/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Users/SSK/Desktop/qtProjects/build-testModBus-Desktop_Qt_5_2_1_MinGW_32bit-Release'
g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release\testModBus.exe release/main.o release/modbus.o release/modbus-data.o release/modbus-rtu.o release/modbus-tcp.o -lglu32 -lopengl32 -lgdi32 -luser32 -LE:\Qt\5.2.1\mingw48_32\lib -lQt5Widgets -lQt5Gui -lQt5Core
release/modbus-tcp.o:modbus-tcp.c:(.text+0x24f): undefined reference to `_imp__select#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x2a3): undefined reference to `_imp__recv#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x2d7): undefined reference to `_imp__recv#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x30d): undefined reference to `_imp__shutdown#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x31c): undefined reference to `_imp__closesocket#4'
Makefile.Release:85: recipe for target 'release\testModBus.exe' failed
release/modbus-tcp.o:modbus-tcp.c:(.text+0x363): undefined reference to `_imp__setsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x394): undefined reference to `_imp__ioctlsocket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x3c6): undefined reference to `_imp__connect#12'
mingw32-make[1]: Leaving directory 'C:/Users/SSK/Desktop/qtProjects/build-testModBus-Desktop_Qt_5_2_1_MinGW_32bit-Release'
makefile:34: recipe for target 'release' failed
release/modbus-tcp.o:modbus-tcp.c:(.text+0x3e2): undefined reference to `_imp__WSAGetLastError#0'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x444): undefined reference to `_imp__select#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x47f): undefined reference to `_imp__getsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x517): undefined reference to `_imp__send#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x597): undefined reference to `_imp__WSAStartup#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x624): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x65e): undefined reference to `_imp__htons#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x66f): undefined reference to `_imp__inet_addr#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x6c8): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x74c): undefined reference to `_imp__getaddrinfo#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x780): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x7bb): undefined reference to `_imp__freeaddrinfo#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x7d5): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x82f): undefined reference to `gai_strerrorW'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x8bc): undefined reference to `_imp__select#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x96c): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x9ab): undefined reference to `_imp__setsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0x9f0): undefined reference to `_imp__htons#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa0a): undefined reference to `_imp__inet_addr#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa2a): undefined reference to `_imp__bind#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa45): undefined reference to `_imp__listen#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa69): undefined reference to `_imp__htonl#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xa85): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xb38): undefined reference to `_imp__getaddrinfo#16'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xb89): undefined reference to `_imp__setsockopt#20'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xb99): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xbc8): undefined reference to `_imp__socket#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xbf9): undefined reference to `_imp__freeaddrinfo#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc23): undefined reference to `_imp__bind#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc33): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc63): undefined reference to `_imp__listen#8'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xc77): undefined reference to `_imp__freeaddrinfo#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xca5): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xcda): undefined reference to `gai_strerrorW'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xd61): undefined reference to `_imp__accept#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xd8b): undefined reference to `_imp__inet_ntoa#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xdc8): undefined reference to `_imp__closesocket#4'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xe19): undefined reference to `_imp__accept#12'
release/modbus-tcp.o:modbus-tcp.c:(.text+0xe57): undefined reference to `_imp__closesocket#4'
e:/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: release/modbus-tcp.o: bad reloc address 0x250 in section `.rdata'
e:/qt/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [release\testModBus.exe] Error 1
mingw32-make: *** [release] Error 2
18:03:04: The process "E:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
You need to include ws2_32.lib in your dependencies. I.e. in your *.pro file add the line:
LIBS += -lws2_32
Turns out that the error was generated because of __declspec(dllexport) in one of the header files. Removed that and it went away. Then it started throwing a new error which is where I'm currently stuck at.

linker error while building roborobo using SDL

I'm using robo robo simulator. It requires SDL to be installed. SDL was successfully installed using sudo apt-get install in Ubuntu
'make' was used to compile and link.
compilation was successful but while linking I got the following linker errors
[LD] roborobo
src/core/roborobo.o: In function `clean_up()':
roborobo.cpp:(.text+0x29): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x35): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x41): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x4d): undefined reference to `SDL_FreeSurface'
roborobo.cpp:(.text+0x59): undefined reference to `SDL_FreeSurface'
src/core/roborobo.o:roborobo.cpp:(.text+0x6a): more undefined references to `SDL_FreeSurface' follow
src/core/roborobo.o: In function `checkQuitEvent()':
roborobo.cpp:(.text+0xdff): undefined reference to `SDL_PollEvent'
src/core/roborobo.o: In function `handleKeyEvent(unsigned char*)':
roborobo.cpp:(.text+0xead): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0xf1a): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0xf43): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0x1037): undefined reference to `SDL_Delay'
roborobo.cpp:(.text+0x111e): undefined reference to `SDL_Delay'
src/core/roborobo.o:roborobo.cpp:(.text+0x1191): more undefined references to `SDL_Delay' follow
and many more
SDL_gfxPrimitives.c:(.text+0x7477): undefined reference to `SDL_UnlockSurface'
SDL_gfxPrimitives.c:(.text+0x7491): undefined reference to `SDL_UpperBlit'
SDL_gfxPrimitives.c:(.text+0x74e6): undefined reference to `SDL_CreateRGBSurface'
collect2: error: ld returned 1 exit status
make: [roborobo] Error 1 (ignored)
the make file also has sdl-config --cflags --libs -lSDL_image
the Makefile is in http://pastebin.com/5EdcZWAd
the entire console output after 'make' is in http://pastebin.com/yXDHR9xw

synergy won't compile -- undefined reference to `pthread_xxxx

When following the build instructions for Synergy, I get the following errors.
Is there an already-developed solution to get Synergy to build?
If not, how do I get Synergy to compile on Ubuntu 13.10?
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::newMutex()':
CArchMultithreadPosix.cpp:(.text+0x319): undefined reference to `pthread_mutexattr_init'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::raiseSignal(IArchMultithread::ESignal)':
CArchMultithreadPosix.cpp:(.text+0x43b): undefined reference to `pthread_kill'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::threadSignalHandler(void*)':
CArchMultithreadPosix.cpp:(.text+0x490): undefined reference to `pthread_detach'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::closeThread(CArchThreadImpl*)':
CArchMultithreadPosix.cpp:(.text+0x62b): undefined reference to `pthread_detach'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::newThread(void* (*)(void*), void*)':
CArchMultithreadPosix.cpp:(.text+0x8e6): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x90f): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x935): undefined reference to `pthread_create'
CArchMultithreadPosix.cpp:(.text+0x9a4): undefined reference to `pthread_create'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::CArchMultithreadPosix()':
CArchMultithreadPosix.cpp:(.text+0xe11): undefined reference to `pthread_mutexattr_init'
CArchMultithreadPosix.cpp:(.text+0xf05): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0xf26): undefined reference to `pthread_sigmask'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::startSignalHandler()':
CArchMultithreadPosix.cpp:(.text+0x10a8): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x10cd): undefined reference to `pthread_sigmask'
CArchMultithreadPosix.cpp:(.text+0x1104): undefined reference to `pthread_create'
../../../../../lib/libarch.a(CArchMultithreadPosix.o): In function `CArchMultithreadPosix::cancelThread(CArchThreadImpl*)':
CArchMultithreadPosix.cpp:(.text+0x5e3): undefined reference to `pthread_kill'
collect2: error: ld returned 1 exit status
make[2]: *** [../../bin/synergyd] Error 1
make[1]: *** [src/cmd/synergyd/CMakeFiles/synergyd.dir/all] Error 2
make: *** [all] Error 2
Going back to: /usr/local/src/synergy-1.4.15-Source
Error: make failed: 512
SOLUTION: manually change the order of the contents of /synergy-1.4.15-Source/src/cmd/synergyd/CMakeFiles/synergyd.dir/link.txt to put -lpthread contents last.
You'd rather edit the CMakelists.txt file to add pthread at the end of the target_link_libraries command.
You may also add link_libraries(pthread).