ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hey

Thanks

I have tried to use rosbuild_remove_link_flags(). Something is wrong. I can't seem to make it work. No matter what I write there, it is always the same linking instruction.

I have also tried to print using CMakeLists.txt the variables ROS uses for creating the linking instruction and they are empty?

Do you know what i could be doing wrong?

Here is my CMakeLists.txt . My executable is named olaola. It links to libs triclops and pgrstereo and to all the ones in ROS.

1 cmake_minimum_required(VERSION 2.4.6) 2 include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) 3 4 # Set the build type. Options are: 5 # Coverage : w/ debug symbols, w/o optimization, w/ code-coverage 6 # Debug : w/ debug symbols, w/o optimization 7 # Release : w/o debug symbols, w/ optimization 8 # RelWithDebInfo : w/ debug symbols, w/ optimization 9 # MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries 10 #set(ROS_BUILD_TYPE Coverage) 11 set(ROS_BUILD_TYPE Debug) 12 13 rosbuild_init() 14 15 #set the default path for built executables to the "bin" directory 16 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 17 #set the default path for built libraries to the "lib" directory 18 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 19 20 #Adding triclops include directory 21 include_directories(/usr/local/include/triclops) 22 23 #Creating a pgr library 24 rosbuild_add_library(pgrlibdcstereo src/pgr_conversions.cpp src/pgr_registers. cpp src/pgr_stereocam.cpp) 25 26 #Creating olaola executable 27 rosbuild_add_executable(olaola src/test.cpp) 28 rosbuild_add_compile_flags(olaola -I/usr/local/include/triclops) 29 link_directories(/usr/local/lib/triclops/) 30 31 #Adding target link libs 32 target_link_libraries(olaola triclops) 33 target_link_libraries(olaola pnmutils) 34 target_link_libraries(olaola pgrlibdcstereo) 35 36 #Removing link and compile flags. Tried several none works 37 rosbuild_remove_link_flags(olaola "-Wl") 38 rosbuild_remove_link_flags(olaola "-lboost_thread-mt") 39 rosbuild_remove_compile_flags(olaola "-Wl") 40 41 #A test to try to figure out outs inside the CMAKE vars. the TESTVAR is just t o be sure I know how to print a variable. The other are to print the variable ROS uses for crating the linking instruction.
42 set(TESTVAR "this is the content of the test var") 43 MESSAGE("TESTVAR = ${TESTVAR}") 44 45 MESSAGE(STATUS "MYLINKFLAGS ARE =" ${LINK_FLAGS}) 46 MESSAGE(STATUS "MY CMAKE_EXE_LINKER_FLAGS ARE =" ${CMAKE_EXE_LINKER_FLAGS}) 47 MESSAGE(STATUS "MY ROS_LINK_LIBS =" ${ROS_LINK_LIBS})

And the output of these prints is:

mike@BLACKBANDIT:~/workingcopy/arpua/sensors/camera/xb3$ make -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- 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 [rosbuild] Building package xb3 [rosbuild] Cached build flags older than manifests; calling rospack to get flags [rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/rospy/cmake/rospy.cmake [rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/roslisp/cmake/roslisp.cmake [rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake -- MYLINKFLAGS ARE = -- MY CMAKE_EXE_LINKER_FLAGS ARE = -- MY ROS_LINK_LIBS = TESTVAR = this is the content of the test var -- Configuring done -- Generating done -- Build files have been written to: /home/mike/workingcopy/arpua/sensors/camera/xb3 Scanning dependencies of target rospack_genmsg_libexe [ 0%] Built target rospack_genmsg_libexe Scanning dependencies of target rosbuild_precompile [ 0%] Built target rosbuild_precompile Scanning dependencies of target pgrlibdcstereo [ 75%] Built target pgrlibdcstereo Scanning dependencies of target olaola [100%] Built target olaola

Thanks

Miguel

click to hide/show revision 2
Just added new lines to better see the print of the variables

Hey

Thanks

I have tried to use rosbuild_remove_link_flags(). Something is wrong. I can't seem to make it work. No matter what I write there, it is always the same linking instruction.

I have also tried to print using CMakeLists.txt the variables ROS uses for creating the linking instruction and they are empty?

Do you know what i could be doing wrong?

Here is my CMakeLists.txt . My executable is named olaola. It links to libs triclops and pgrstereo and to all the ones in ROS.

1 cmake_minimum_required(VERSION 2.4.6) 2 include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) 3 4 # Set the build type. Options are: 5 # Coverage : w/ debug symbols, w/o optimization, w/ code-coverage 6 # Debug : w/ debug symbols, w/o optimization 7 # Release : w/o debug symbols, w/ optimization 8 # RelWithDebInfo : w/ debug symbols, w/ optimization 9 # MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries 10 #set(ROS_BUILD_TYPE Coverage) 11 set(ROS_BUILD_TYPE Debug) 12 13 rosbuild_init() 14 15 #set the default path for built executables to the "bin" directory 16 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 17 #set the default path for built libraries to the "lib" directory 18 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) 19 20 #Adding triclops include directory 21 include_directories(/usr/local/include/triclops) 22 23 #Creating a pgr library 24 rosbuild_add_library(pgrlibdcstereo src/pgr_conversions.cpp src/pgr_registers. cpp src/pgr_stereocam.cpp) 25 26 #Creating olaola executable 27 rosbuild_add_executable(olaola src/test.cpp) 28 rosbuild_add_compile_flags(olaola -I/usr/local/include/triclops) 29 link_directories(/usr/local/lib/triclops/) 30 31 #Adding target link libs 32 target_link_libraries(olaola triclops) 33 target_link_libraries(olaola pnmutils) 34 target_link_libraries(olaola pgrlibdcstereo) 35 36 #Removing link and compile flags. Tried several none works 37 rosbuild_remove_link_flags(olaola "-Wl") 38 rosbuild_remove_link_flags(olaola "-lboost_thread-mt") 39 rosbuild_remove_compile_flags(olaola "-Wl") 40 41 #A test to try to figure out outs inside the CMAKE vars. the TESTVAR is just t o be sure I know how to print a variable. The other are to print the variable ROS uses for crating the linking instruction.
42 set(TESTVAR "this is the content of the test var") 43 MESSAGE("TESTVAR = ${TESTVAR}") 44 45 MESSAGE(STATUS "MYLINKFLAGS ARE =" ${LINK_FLAGS}) 46 MESSAGE(STATUS "MY CMAKE_EXE_LINKER_FLAGS ARE =" ${CMAKE_EXE_LINKER_FLAGS}) 47 MESSAGE(STATUS "MY ROS_LINK_LIBS =" ${ROS_LINK_LIBS})

And the output of these prints is:

mike@BLACKBANDIT:~/workingcopy/arpua/sensors/camera/xb3$ make -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- 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 [rosbuild] Building package xb3 [rosbuild] Cached build flags older than manifests; calling rospack to get flags [rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/rospy/cmake/rospy.cmake [rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/roslisp/cmake/roslisp.cmake [rosbuild] Including /opt/ros/diamondback/stacks/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake /opt/ros/diamondback/stacks/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake

-- MYLINKFLAGS ARE = =

-- MY CMAKE_EXE_LINKER_FLAGS ARE = =

-- MY ROS_LINK_LIBS = =

TESTVAR = this is the content of the test var var

-- Configuring done -- Generating done -- Build files have been written to: /home/mike/workingcopy/arpua/sensors/camera/xb3 Scanning dependencies of target rospack_genmsg_libexe [ 0%] Built target rospack_genmsg_libexe Scanning dependencies of target rosbuild_precompile [ 0%] Built target rosbuild_precompile Scanning dependencies of target pgrlibdcstereo [ 75%] Built target pgrlibdcstereo Scanning dependencies of target olaola [100%] Built target olaola

Thanks

Miguel