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

Compile fails on OSX ... can't find library rt #24

Closed
walchko opened this issue Dec 2, 2012 · 1 comment
Closed

Compile fails on OSX ... can't find library rt #24

walchko opened this issue Dec 2, 2012 · 1 comment

Comments

@walchko
Copy link

walchko commented Dec 2, 2012

Looking at your CMakeLists.txt I don't think you want to add rt unless you are linux. I get the following error when it tries to build:

[kevin@tardis serial]$ make
cd build && cmake -DCMAKE_INSTALL_PREFIX=/tmp/usr/local ..
-- The C compiler identification is Clang 4.1.0
-- The CXX compiler identification is Clang 4.1.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using CATKIN_DEVEL_PREFIX: /Users/kevin/tmp/serial/build/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/groovy
-- This workspace overlays: /opt/ros/groovy
-- Found PythonInterp: /usr/bin/python (found version "2.7.2") 
-- Found PY_em: /Library/Python/2.7/site-packages/em.pyc  
-- Found gtest: gtests will be built
-- catkin 0.5.52
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/kevin/tmp/serial/build
cd build && make
Scanning dependencies of target serial
[ 33%] Building CXX object CMakeFiles/serial.dir/src/serial.cc.o
[ 66%] Building CXX object CMakeFiles/serial.dir/src/impl/unix.cc.o
Linking CXX shared library devel/lib/libserial.dylib
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [devel/lib/libserial.dylib] Error 1
make[2]: *** [CMakeFiles/serial.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [serial] Error 2

You need to change CMakeLists.txt where you add library rt:

 if (UNIX AND NOT APPLE)
    target_link_libraries(${PROJECT_NAME} rt)
endif()

Here is the diff:

[kevin@tardis serial]$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ea1c80..216bc04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,7 @@ endif()
 add_library(${PROJECT_NAME}
     ${serial_SRCS}
 )
-if (UNIX)
+if (UNIX AND NOT APPLE)
     target_link_libraries(${PROJECT_NAME} rt)
 endif()
@wjwwood
Copy link
Owner

wjwwood commented Dec 3, 2012

Thanks, I actually had that before, but must have missed it in the move to catkin:

if(UNIX AND NOT APPLE)

I'll get a fix for this asap.

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

2 participants