Opencv未定义的架构符号?

时间:2014-03-29 18:34:26

标签: c++ opencv makefile include

Undefined symbols for architecture x86_64:
  "cv::_InputArray::_InputArray(cv::Mat const&)", referenced from:
      HDRDisplay::DisplaySplitImage(cv::Mat, double) in HDRDisplay.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1

我需要一些帮助来理解这个错误,我已经非常可能地包含了每个opencv2文件,但我不知道为什么它可以&cv :: _ InputArray :: _ InputArray(cv :: Mat const&) ?它是否包含在我没有包含的内容中?

请参阅下面的Makefile:

main: main.o Screen.o HDRDisplay.o
    g++ -o main main.o Screen.o HDRDisplay.o -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -L/usr/local/lib -I/usr/include/opencv -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann 

HDRDisplay.o: HDRDisplay.cpp HDRDisplay.h
g++ -c HDRDisplay.cpp -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -L/usr/local/lib -I/usr/include/opencv -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann 

Screen.o: Screen.cpp Screen.h
     g++ -c Screen.cpp -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -L/usr/local/lib -I/usr/include/opencv -lopencv_core -lopencv_imgproc -  lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann 

main.o: main.cpp Screen.h HDRDisplay.h
    g++ -c main.cpp -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -L/usr/local/lib -I/usr/include/opencv -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

这是我的main.cpp

#include "HDRDisplay.h"
#include "Screen.h"
#include <Opencv2/highgui/highgui.hpp>
#include <iostream>


using namespace std;

int main(int argc, char* argv[])
{
cv::VideoCapture cap("movie.mov"); // open the video file for reading

if ( !cap.isOpened() )  // if not success, exit program
{
     cout << "Cannot open the video file" << endl;
     return -1;
}

//cap.set(CV_CAP_PROP_POS_MSEC, 300); //start the video at 300ms

double fps = cap.get(cv::CAP_PROP_FPS); //get the frames per seconds of the video

 cout << "Frame per seconds : " << fps << endl;

//namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

while(1)
{
    cv::Mat frame;

    bool bSuccess = cap.read(frame); // read a new frame from video

     if (!bSuccess) //if not success, break loop
    {
                    cout << "Cannot read the frame from video file" << endl;
                   break;
    }

    Screen front(2,2560,1600);
    Screen back(1,1280,800);
    HDRDisplay HDRD(front,back);

    HDRD.DisplaySplitImage(frame,1); //show the frame in "MyVideo" window

    if(cv::waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop
   {
            cout << "esc key is pressed by user" << endl; 
            break; 
   }
}

return 0;

}

1 个答案:

答案 0 :(得分:0)

尝试使用$(pkg-config --libs --cflags opencv)替换这些标记。