mineserver
mineserver copied to clipboard
Missing librt in compiler build flags
Hi, When I'm trying to compile mineserver in ArchLinux x86_64 envorinoment, I get this:
[rz2k@Derneuca mineserver]$ make all
Linking CXX executable ../bin/mineserver
/usr/bin/ld: CMakeFiles/mineserver.dir/tools.cpp.o: undefined reference to symbol 'clock_gettime@@GLIBC_2.2.5'
/usr/bin/ld: note: 'clock_gettime@@GLIBC_2.2.5' is defined in DSO /usr/lib/librt.so.1 so try adding it to the linker command line
/usr/lib/librt.so.1: could not read symbols: Invalid operation
This is easy fixable with:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9be9356..1a03255 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -95,7 +95,7 @@ SET(LIBRARY_OUTPUT_PATH bin)
# Set compiler specific build flags
IF(CMAKE_COMPILER_IS_GNUCXX)
- SET(CMAKE_CXX_FLAGS "-W -Wall -Wno-unused -pedantic -DHAVE_TR1_SUBDIR")
+ SET(CMAKE_CXX_FLAGS "-W -Wall -Wno-unused -pedantic -DHAVE_TR1_SUBDIR -l rt")
SET(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g -O0")
SET(CMAKE_CXX_FLAGS_PROFILE "-DDEBUG -g -pg")
SET(CMAKE_CXX_FLAGS_RELEASE "-O4 -s -DNDEBUG")
Thanks EastByte@IRC for hint.
Is it possible to determine if linker needs librt in CMake scripts before compilation and make a workaround?
Thanks for this awesome project, Best Regards, Dmitriy Beykun.