项目场景:
编译雷达相机项目时遇到PCL和OPENCV的版本号出现的问题:
link library [libpcl_io.so] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/usr/local/lib
usr/bin/ld: warning: libopencv_core.so.3.4, needed by /usr/local/lib/libopencv_features2d.so.3.4.0, may conflict with libopencv_core.so.4.2
解决方案:
PCL:
Cmakelists中原本
find_package(PCL REQUIRED)
重新指定路径,排除自带的文件,改为:
set(PCL_DIR "/usr/local/lib/") find_package(PCL 1.8 REQUIRED) file(GLOB_RECURSE OLD_PCL "/usr/lib/x86_64-linux-gnu/libpcl*") list(REMOVE_ITEM catkin_LIBRARIES ${OLD_PCL}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS})
OPENCV:
按照pcl同样的方法修改后仍报错,直接修改cv_bridge中的内容:
打开 /opt/ros/noetic/share/cv_bridge/cmake/cv_bridgeConfig.cmake 进行替换
1)
#if(NOT "include;/usr/include/opencv4 " STREQUAL " ")
==>
if(NOT "include;/usr/local/include/opencv " STREQUAL " ")
#set(_include_dirs "include;/usr/include/opencv4")
==>
set(_include_dirs "include;/usr/local/include/opencv")
"/usr/local/include/opecncv"是自己安装的路径
2) 替换lib的路径,注意自己安装路径中没有的lib需要删掉。
set(libraries "cv_bridge;/usr/include/x86_64-linux-gnu/.....
==>
set(libraries "cv_bridge;/usr/local/lib/libopencv_calib3d.so.3.4.0;....