You should ensure that -lpthread -lrt appear after your libraries like ../lib/libLibUtil.a.
Up vote 0 down vote favorite share g+ share fb share tw.
I'm having a link error under cmake that I don't have when compiling on a system with an older version of gcc. The specific error is "undefined reference to clock_gettime" but -lrt is appearing on the command line. My gcc version: gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Cmake version 2.8.5 I am including the required "-lrt" through target_link_libraries in my CMakeLists.
Txt file. I can see it appear in the compiler line with make VERBOSE=1 I've read that gcc 4.6 is picky about the position of link libraries on the command line. How can I fix this for CMake?
EDIT: Link line Linking CXX executable ../bin/obbsd cd /home/matt/Desktop/Matt/OBBS/Build/server && /usr/bin/cmake -E cmake_link_script \ CMakeFiles/obbsd. Dir/link. Txt --verbose=1 /usr/bin/c++ -g CMakeFiles/obbsd.
Dir/Block.cpp. O \ CMakeFiles/obbsd. Dir/BlockFileCache.cpp.
O \ CMakeFiles/obbsd. Dir/BlockFileStore.cpp. O \ CMakeFiles/obbsd.
Dir/BlockMemoryCache.cpp. O \ CMakeFiles/obbsd. Dir/BlockStore.cpp.
O CMakeFiles/obbsd. Dir/Config.cpp. O \ CMakeFiles/obbsd.
Dir/DeleteBlockSession.cpp. O \ CMakeFiles/obbsd. Dir/mConfigFile.cpp.
O \ CMakeFiles/obbsd. Dir/mNetworkPacketReader.cpp. O \ CMakeFiles/obbsd.
Dir/mNetworkPacketWriter.cpp. O \ CMakeFiles/obbsd. Dir/obbsd.cpp.
O \ CMakeFiles/obbsd. Dir/ReadBlockSession.cpp. O CMakeFiles/obbsd.
Dir/Server.cpp. O \ CMakeFiles/obbsd. Dir/Session.cpp.
O CMakeFiles/obbsd. Dir/Utility.cpp. O \ CMakeFiles/obbsd.
Dir/WriteBlockSession.cpp. O -o ../bin/obbsd -rdynamic \ -lpthread -lrt ../lib/libLibUtil. A ../lib/libLibUtil.
A(mTimer.cpp. O): In function `mTimer::GetTick()': /home/matt/Desktop/Matt/OBBS/LibUtil/src/mTimer. Cpp:108: undefined reference to `clock_gettime' Why is ../lib/libLibUtil.
A appearing after -lrt when LibUtil (what would be libLibUtil. A) is before rt? CMakeLists.
Txt includes... ... add_executable(obbsd ${SERVER_SOURCE_FILES}) find_package(Threads REQUIRED) target_link_libraries(obbsd ${CMAKE_THREAD_LIBS_INIT} LibUtil rt) gcc cmake linker-error link|improve this question edited Mar 1 at 6:25Jonathan Leffler140k10108268 asked Mar 1 at 6:06Matt H4,4511235 87% accept rate.
1 Try to put -lrt add the end of your list of libraries. And show us the exact linking command – Basile Starynkevitch Mar 1 at 6:09 @BasileStarynkevitch - updated. – Matt H Mar 1 at 6:17.
I know that is the problem. But how do I force cmake to make that happen? – Matt H Mar 1 at 6:27 Ok, my bad.
I was compiling a copy of the project not the one I was editing! Indeed, moving rt after libutil fixed it. – Matt H Mar 1 at 6:35 Curiously, why does gcc 4.6 have this pickyness?
– Matt H Mar 1 at 6:36 It is not specific to GCC, nor to any of its version; it is the way Unix linkers (i.e. Ld command from binutils package on Linux) work, since the very first Unixes. – Basile Starynkevitch Mar 1 at 6:38 Except I can link this on another machine that is ubuntu 11.04. This one is 11.10 – Matt H Mar 1 at 6:49.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.