[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

question

When compiling with cmake, cmake can also find opencv4, but an error is reported during compilation:

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

solution

This is because there is an additional opencv4 folder in the path of the opencv header file: /usr/include/opencv4/opencv2.

You can copy opencv2 to your own include folder
You can link the opencv2 folder to the include folder
 

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....


 

Guess you like

Origin blog.csdn.net/weixin_47552638/article/details/124081537