Problem with OpenCV: undefined reference to 'cv::Mat::Mat()'

Reference: Learn ROS2 hands-on

Analyze the reasons:

undefined reference to 'cv::Mat::Mat()'

The reason is that g++ cannot find the library file. The solution is that we help it locate the library file and specify the library directory through the -L parameter, and -l (lowercase L) specifies the name of the library.

Solution:

Add suffix parameters when executing commands

g++ main_map.cpp -L /home/wcx/opencv-4.6.0/build/install/lib -lopencv_core -lopencv_imgproc -lopencv_highgui

 

Guess you like

Origin blog.csdn.net/qq_45461410/article/details/132109155