How to change directory of a library in a package in ros ubuntu

梦想与她 提交于 2019-12-12 17:10:33

问题


I have installed opencv2.4.9(With No CUDA) by unzip opencv2.4.9.zip in home. Many successful codes are using this library. Now I wanna rebuild opencv2.4.9(with CUDA) in another folder. I don't wanna delete the previous folder because I don't wanna face any problem later on and make my older code can't function.

So, the question is how to change the name of the directory? Seems like we link the package with library in CMake like below:

include_directories( ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )

find_package( OpenCV REQUIRED )

find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport OpenCV roscpp rospy std_msgs )

the name of directory is just OpenCV. So if I got more than one OpenCV library in home, how could I link them separately?

And how to make c++ link to the library if we could change the name?

add_executable(xxx src/xxx.cpp)

target_link_libraries(xxx ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

回答1:


Libraries can be included and linked with include_directories() and link_directories(), like this:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
...
include_directories(${PROJECT_SOURCE_DIR})

include_directories(/path/to/opencv/OpenCV-2.4.1/include)
link_directories(/path/to/opencv/OpenCV-2.4.1/lib)
...

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o op ...

So you should not forget the linking in the CMakeLists.txt and maybe remove the standard linking to your current OpenCV libs.



来源:https://stackoverflow.com/questions/33931153/how-to-change-directory-of-a-library-in-a-package-in-ros-ubuntu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!