Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing librt in compiler build flags #209

Open
rzk opened this issue Aug 16, 2012 · 0 comments
Open

Missing librt in compiler build flags #209

rzk opened this issue Aug 16, 2012 · 0 comments

Comments

@rzk
Copy link

rzk commented Aug 16, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant