尝试与opencv链接时出现编译器错误

时间:2020-06-24 10:09:01

标签: c++ opencv

g++ -I/usr/local/include/opencv4/ face.cpp -L -lopencv_core -lopencv_highgui

错误:

/usr/bin/ld: /tmp/cceoykhK.o: undefined reference to symbol '_ZN2cv12equalizeHistERKNS_11_InputArrayERKNS_12_OutputArrayE'
/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

编译时出现以下错误。我该怎么办?

我添加了-lopencv_imgproc

g++ -I/usr/local/include/opencv4/ face.cpp -L -lopencv_core -lopencv_highgui -lopencv_imgproc

错误:

/usr/bin/ld: /tmp/ccBOnCLF.o: undefined reference to symbol '_ZN2cv3MatC1ERKS0_RKNS_5Rect_IiEE'
    //usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status

我尝试使用

g++ -I/usr/local/include/opencv4/ -L/usr/local/lib face.cpp  -lopencv_objdetect -lopencv_features2d -lopencv_imgproc -lopencv_highgui -lopencv_core

错误:

face.cpp:(.text+0x5b): undefined reference to `cv::VideoCapture::VideoCapture()'
face.cpp:(.text+0x179): undefined reference to `cv::VideoCapture::open(int, int)'
face.cpp:(.text+0x188): undefined reference to `cv::VideoCapture::isOpened() const'
face.cpp:(.text+0x1b1): undefined reference to `cv::VideoCapture::operator>>(cv::Mat&)'
face.cpp:(.text+0x2e5): undefined reference to `cv::VideoCapture::~VideoCapture()'
face.cpp:(.text+0x3b5): undefined reference to `cv::VideoCapture::~VideoCapture()'
collect2: error: ld returned 1 exit status

完成

g++ -I/usr/local/include/opencv4/ -L/usr/local/lib face.cpp  -lopencv_objdetect -lopencv_features2d -lopencv_imgproc -lopencv_highgui -lopencv_core -lopencv_videoio

0 个答案:

没有答案