如何在ros ubuntu中改变包中的库的目录 [英] How to change directory of a library in a package in ros ubuntu
问题描述
我已经安装opencv2.4.9(没有CUDA)通过解压opencv2.4.9.zip在家里。
许多成功的代码正在使用此库。
现在我想在另一个文件夹中重建opencv2.4.9(使用CUDA)。
我不想删除以前的文件夹,因为我不想面对任何问题,使我的旧代码不能运作。
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})
include_directories( ${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )
find_package(OpenCV REQUIRED)
find_package( OpenCV REQUIRED )
find_package(catkin必需组件cv_bridge image_transport
OpenCV roscpp rospy std_msgs)
find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport OpenCV roscpp rospy std_msgs )
目录的名称只是OpenCV。
所以如果我在家里有多个OpenCV库,我们如何分别链接它们?
the name of directory is just OpenCV. So if I got more than one OpenCV library in home, how could I link them separately?
如果我们可以使c ++链接到库更改名称?
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})
推荐答案
库可以包含并链接到 include_directories()
和 link_directories()
,如下所示:
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 ...
所以你不应该忘记链接在 CMakeLists.txt
,也许删除标准链接到你当前的OpenCV库。
So you should not forget the linking in the CMakeLists.txt
and maybe remove the standard linking to your current OpenCV libs.
这篇关于如何在ros ubuntu中改变包中的库的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!