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