【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 statusnavigation-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' failedmake[2]: *** [/home/nvidia/dev_paotou/catkin_make/devel/lib/map_server/map_server] Error 1CMakeFiles/Makefile2:888: recipe for target 'navigation-melodic/map_server/CMakeFiles/map_server.dir/all' failedmake[1]: *** [navigation-melodic/map_server/CMakeFiles/map_server.dir/all] Error 2Makefile:140: recipe for target 'all' failedmake: *** [all] Error 2Invoking "make -j8 -l8" failed
CMakeLists.txt
target_link_libraries(map_servermap_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 statusnavigation-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' failedmake[2]: *** [/home/nvidia/dev_paotou/catkin_make/devel/lib/costmap_2d/costmap_2d_node] Error 1CMakeFiles/Makefile2:12404: recipe for target 'navigation-melodic/costmap_2d/CMakeFiles/costmap_2d_node.dir/all' failedmake[1]: *** [navigation-melodic/costmap_2d/CMakeFiles/costmap_2d_node.dir/all] Error 2make[1]: *** Waiting for unfinished jobs....