OpenCv链接错误(gcc,windows 7 x64)

时间:2014-07-16 06:52:39

标签: c++ opencv gcc linker linker-errors

我在Linux上编写了OpenCv程序。 现在我将它移植到Windows(gcc,windows 7 x64)。

包括:

#include <opencv2/core/core.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

Linux上的编译命令(运行良好):

g++ `pkg-config --libs --cflags opencv` -I. -o tester tester.c  -lopencv_core 
-lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

Windows上的编译命令是:

g++ -I"C:/opencv/build/include" -L"C:\opencv\build\x86\vc12\lib"
tester.cpp  -lopencv_core249 -lopencv_calib3d249
-lopencv_imgproc249 -lopencv_highgui249 -lopencv_objdetect249 -o tester

我最后一次使用vc12 opencv libs进行调整时,它运行良好。

编译错误是:

C:\Users\Lukasz\AppData\Local\Temp\ccZXWyKF.o:tester.cpp:(.text+0x115): undefine
d reference to `cv::CascadeClassifier::load(std::string const&)'
C:\Users\Lukasz\AppData\Local\Temp\ccZXWyKF.o:tester.cpp:(.text+0x194): undefine
d reference to `cv::VideoCapture::VideoCapture(std::string const&)'
C:\Users\Lukasz\AppData\Local\Temp\ccZXWyKF.o:tester.cpp:(.text+0x1be): undefine
d reference to `cv::VideoCapture::isOpened() const'
C:\Users\Lukasz\AppData\Local\Temp\ccZXWyKF.o:tester.cpp:(.text+0x208): undefine
d reference to `cv::VideoCapture::get(int)'

(...)

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\L
ukasz\AppData\Local\Temp\ccZXWyKF.o: bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status

这可能是一个非常蹩脚的问题,但我需要有新面貌的人。我累了。

我使用的是awfull CMD和PowerShell ......但是在MinGW shell中(C:\ MinGW \ msys \ 1.0) - 使用pkg-config时出现同样的错误:

g++ `pkg-config --cflags opencv` -I. -o tester tester.c  -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect `pkg-config --libs opencv`

sh: pkg-congfig: command not found

0 个答案:

没有答案