我是新來的Qt和OpenCV,我儘量讓用一個簡單的代碼項目:未定義參考QT OpenCV的
中的.pro:
QT += core
QT -= gui
QT += widgets
TARGET = latihan_2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += E:\\OpenCV\\OpenCV\\opencv\\build\\include
LIBS += E:\OpenCV\OpenCV\opencv\build\x86\vc10\lib\opencv_core246.lib
LIBS += E:\OpenCV\OpenCV\opencv\build\x86\vc10\lib\opencv_highgui246.lib
LIBS += E:\OpenCV\OpenCV\opencv\build\x86\vc10\lib\opencv_imgproc246.lib
LIBS += E:\OpenCV\OpenCV\opencv\build\x86\vc10\lib\opencv_features2d246.lib
LIBS += E:\OpenCV\OpenCV\opencv\build\x86\vc10\lib\opencv_calib3d246.lib
在main.cpp中
:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(){
//read image
cv::Mat image;
image = cv::imread("img.jpg");
//create image window named "My image"
cv::namedWindow("My Image");
//show the image on window
cv::imshow("My image", image);
//wait key for 5000ms
cv::waitKey(5000);
return 1;
}
但是,它總是給cv :: imread,cv :: namedWindows和我使用的其他CV函數的未定義引用提供錯誤。
我使用Qt Creator的2.8.1,基於Qt 5.1.1,和OpenCV-2.4.6.0
任何幫助將不勝感激! 謝謝
你使用哪種編譯器? 「\ x86 \ vc10」可能意味着opencv是使用Visual C++編譯的。你是否也使用VC++進行項目編譯或使用mingw32? –
我只是將其更改爲: LIBS + = E:\ OpenCV \ OpenCV \ opencv \ build \ x86 \ mingw \ lib \ libopencv_core246.dll。a LIBS + = E:\ OpenCV \ OpenCV \ opencv \ build \ x86 \ mingw \ lib \ libopencv_highgui246.dll.a LIBS + = E:\ OpenCV \ OpenCV \ opencv \ build \ x86 \ mingw \ lib \ libopencv_imgproc246。 dll.a LIBS + = E:\ OpenCV \ OpenCV \ opencv \ build \ x86 \ mingw \ lib \ libopencv_features2d246.dll.a LIBS + = E:\ OpenCV \ OpenCV \ opencv \ build \ x86 \ mingw \ lib \ libopencv_calib3d246.dll.a ,它的工作!謝謝你,老ufo! – Squirrelcages
不客氣。順便說一句,對於您的簡單應用程序,只需要核心和高級庫。 –