[opencv4]——fatal error: opencv2/opencv.hpp: No such file or directory #include <opencv2/opencv.hpp>

【opencv4】——fatal error: opencv2/opencv.hpp: No such file or directory #include <opencv2/opencv.hpp>

opencv4

问题

采用cmake编译的时候,cmake也能找到opencv4,但是编译时候报错:

fatal error: opencv2/opencv.hpp: No such file or directory
#include <opencv2/opencv.hpp>

解决方案

这是因为opencv头文件的路径中多了一个opencv4的文件夹:/usr/include/opencv4/opencv2,

可以将opencv2拷贝到自己的include文件夹
可以将opencv2文件夹链接到include文件夹下
 

sudo ln -s /usr/include/opencv4/opencv2 /usr/include/

CMakeFiles/map_server.dir/src/main.cpp.o: In function `boost::filesystem::path::operator/=(boost::filesystem::path const&)':
main.cpp:(.text._ZN5boost10filesystem4pathdVERKS1_[_ZN5boost10filesystem4pathdVERKS1_]+0x28): undefined reference to `boost::filesystem::path::append_v3(boost::filesystem::path const&)'
CMakeFiles/map_server.dir/src/main.cpp.o: In function `boost::filesystem::path::parent_path() const':
main.cpp:(.text._ZNK5boost10filesystem4path11parent_pathEv[_ZNK5boost10filesystem4path11parent_pathEv]+0x34): undefined reference to `boost::filesystem::path::find_parent_path_size() const'
CMakeFiles/map_server.dir/src/main.cpp.o: In function `boost::filesystem::path::has_root_directory() const':
main.cpp:(.text._ZNK5boost10filesystem4path18has_root_directoryEv[_ZNK5boost10filesystem4path18has_root_directoryEv]+0x10): undefined reference to `boost::filesystem::path::find_root_directory() const'
collect2: error: ld returned 1 exit status
navigation-melodic/map_server/CMakeFiles/map_server.dir/build.make:140: recipe for target '/home/nvidia/dev_paotou/catkin_make/devel/lib/map_server/map_server' failed
make[2]: *** [/home/nvidia/dev_paotou/catkin_make/devel/lib/map_server/map_server] Error 1
CMakeFiles/Makefile2:888: recipe for target 'navigation-melodic/map_server/CMakeFiles/map_server.dir/all' failed
make[1]: *** [navigation-melodic/map_server/CMakeFiles/map_server.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed

CMakeLists.txt  

target_link_libraries(map_server
    map_server_image_loader
    ${YAMLCPP_LIBRARIES}
    ${catkin_LIBRARIES}
    ${Boost_FILESYSTEM_LIBRARY}
)
/home/nvidia/dev_paotou/catkin_make/devel/lib/libcostmap_2d.so: undefined reference to `boost::filesystem::path::find_parent_path_size() const'
/home/nvidia/dev_paotou/catkin_make/devel/lib/libcostmap_2d.so: undefined reference to `boost::filesystem::path::append_v3(boost::filesystem::path const&)'
/home/nvidia/dev_paotou/catkin_make/devel/lib/libcostmap_2d.so: undefined reference to `boost::filesystem::path::filename_v3() const'
collect2: error: ld returned 1 exit status
navigation-melodic/costmap_2d/CMakeFiles/costmap_2d_node.dir/build.make:133: recipe for target '/home/nvidia/dev_paotou/catkin_make/devel/lib/costmap_2d/costmap_2d_node' failed
make[2]: *** [/home/nvidia/dev_paotou/catkin_make/devel/lib/costmap_2d/costmap_2d_node] Error 1
CMakeFiles/Makefile2:12404: recipe for target 'navigation-melodic/costmap_2d/CMakeFiles/costmap_2d_node.dir/all' failed
make[1]: *** [navigation-melodic/costmap_2d/CMakeFiles/costmap_2d_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....


 

猜你喜欢

转载自blog.csdn.net/weixin_47552638/article/details/124081537
今日推荐