0
我正在尝试使用外部库来构建项目,但系统一直在考虑它需要使用已损坏的usr/lib中的库。我希望改为使用地址内建立的库:/home/CMake-hdf5-1.8.18/build/HDF5-1.8.18-Linux/HDF_Group/HDF5/1.8.18/include。这是CMakeLists.txt。我想要的解决方案是#Add hdf5库下的两行。Reg。使用CMake将外部库链接到项目
cmake_minimum_required(VERSION 2.8.3)
project(scan_to_cloud_converter)
# List C++ dependencies on ros packages
set(ROS_CXX_DEPENDENCIES
roscpp
pcl_ros
pcl_conversions)
# Find catkin and all required ROS components
find_package(catkin REQUIRED COMPONENTS ${ROS_CXX_DEPENDENCIES})
find_package(PCL REQUIRED QUIET)
# Set include directories
include_directories(include ${catkin_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})
# Declare info that other packages need to import library generated here
catkin_package()
#Create node
add_executable(scan_to_cloud_converter_node
src/scan_to_cloud_converter_node.cpp
src/scan_to_cloud_converter.cpp)
#Add hdf5 library
link_directories(/home/CMake-hdf5-1.8.18/build/HDF5-1.8.18-Linux/HDF_Group/HDF5/1.8.18/include)
target_link_libraries(scan_to_cloud_converter_node libhdf5)
# No need to link against pcl (using header only libraries)
target_link_libraries(scan_to_cloud_converter_node ${catkin_LIBRARIES})
add_dependencies(scan_to_cloud_converter_node ${catkin_EXPORTED_TARGETS})
#Install node
install(TARGETS scan_to_cloud_converter_node
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
这是错误消息我仍然得到然而:
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/hdf5/serial/lib/libhdf5.so', needed by '/home/catkin_ws/devel/lib/scan_to_cloud_converter/scan_to_cloud_converter_node'. Stop.
我做研究这个错误,这是因为它仍然在寻找到/ usr/lib和有没有库libhdf5.so,因为符号链接被破坏。那么我怎么才能看到这个库的另一个地址呢?任何帮助消除此错误将不胜感激
奇怪你的库在'.../include'而不是'.../lib'。无论如何,你不应该写'target_link_libraries(scan_to_cloud_converter_node hdf5)'? – xiawi
嗯,实际上有一个libhdf5.a的/ lib文件夹,我应该重定向链接到这个?我应该拥有那个target_link_libraries行吗? – ksivakumar
所以我尝试使用/ lib文件夹以及获取相同的错误。我的直觉是它仍然在/ usr/lib中查看,而没有被重定向到这个新地址,所以不知道如何改变它。 – ksivakumar