2013-07-26 50 views
0

我試圖讓OpenCv2.4.6與QT5.1.0 工作,我已經按照本指南到目前爲止Qt creator 5.0.1 with OpenCv 2.3.4 on windowsOpenCV的2.4.6與5.1.0 QT錯誤

不幸的是整理嘗試示例應用程序之後(顯示在QtCreator使用OpenCV的影像,我得到這些錯誤:

[Project-Path]\main.o:-1: In function `main': 
[Project-Path]\main.cpp:8: error: undefined reference to `cv::imread(std::string const&, int)' 
[Project-Path]\main.cpp:9: error: undefined reference to `cv::namedWindow(std::string const&, int)' 
[Project-Path]\main.cpp:10: error: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)' 
[Project-Path]\main.cpp:10: error: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)' 
[Project-Path]\main.cpp:11: error: undefined reference to `cv::waitKey(int)' 
[Project Build Path Desktop Debug]\debug\main.o:-1: In function `ZN2cv3MatD1Ev': 
    [OpenCV/Install/include]\opencv2\core\mat.hpp:278: error: undefined reference to `cv::fastFree(void*)' 
[Project Build Path Desktop Debug]\debug\main.o:-1: In function `ZN2cv3Mat7releaseEv': 
    [OpenCV/Install/include]\opencv2\core\mat.hpp:367: error: undefined reference to `cv::Mat::deallocate()' 
collect2.exe:-1: error: error: ld returned 1 exit status 

的「[]」路徑是我的格式和應該幫助跟蹤

的main.cpp

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


using namespace cv; 
int main() { 
     // read an image 
     Mat image = imread("img.jpg"); 
     namedWindow("My Image"); 
     imshow("My Image", image); 
     waitKey(5000); 

     return 1; 
} 

myFirstOpenCVProject.pro

QT  += core 
QT  -= gui 
TARGET = myFirstOpenCVProject 
CONFIG += console 
CONFIG -= app_bundle 
TEMPLATE = app 
SOURCES += main.cpp 
INCLUDEPATH += C:/qt/OpenCV246_bin/install/include 
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_core246.dll 
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_highgui246.dll 
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_imgproc246.dll 
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_features2d246.dll 
LIBS += -LC:/qt/OpenCV246_bin/install/lib/lopencv_calib3d246.dll 

你能幫我解決這個問題? 我無法找到適用於我的情況下,任何解決方案...

回答

3

-L是將目錄添加到搜索路徑。實際庫是通過-l添加的。正確的行將是:

LIBS += -LC:/qt/OpenCV246_bin/install/lib -llopencv_core246 -llopencv_highgui246 ... 
0

我認爲你缺少的OpenCV的靜態庫:

opencv_core246.lib 
opencv_highgui246.lib 
opencv_video246.lib 
opencv_ml26d.lib 
opencv_legacy246.lib 
opencv_imgproc246.lib 
opencv_whatever.lib 

唐知道親的命令非常好。可能是這樣的:

LIBS += -Lc:/blabla/opencv_imgproc246.lib