我已經QT安裝在我的電腦,它是使用Visual Studio 2010的編譯器未找到文件main.obj
我用一個簡單的Hello World應用程序進行了測試,它工作正常。
但是現在我正嘗試在QT中使用OpenCV。我已經安裝了Visual Studio 2010 express和professional,並且opencv在那裏工作得很好。但是,當我嘗試運行QT OpenCV的,我得到以下錯誤
main.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" ([email protected]@[email protected]@QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" ([email protected]@[email protected]@QAEXXZ)
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" ([email protected]@@[email protected]) referenced in function "public: __thiscall cv::Mat::~Mat(void)" ([email protected]@@[email protected])
main.obj:-1: error: LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" ([email protected]@@[email protected]) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" ([email protected]@@[email protected]@[email protected]@Z) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" ([email protected]@@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function _main
release\FirstProject.exe:-1: error: LNK1120: 7 unresolved externals
以下是我FirstProject.pro文件的內容
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-26T11:15:33
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = FirstProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\opencv\build\include\
LIBS += -LC:\opencv\build\x86\vc10\lib \
-lopencv_calib3d240d.lib\
-lopencv_contrib240d.lib\
-lopencv_core240d.lib\
-lopencv_features2d240d.lib\
-lopencv_flann240d.lib\
-lopencv_gpu240d.lib\
-lopencv_haartraining_engined.lib\
-lopencv_highgui240d.lib\
-lopencv_imgproc240d.lib\
-lopencv_legacy240d.lib\
-lopencv_ml240d.lib\
-lopencv_nonfree240d.lib\
-lopencv_objdetect240d.lib\
-lopencv_photo240d.lib\
-lopencv_stitching240d.lib\
-lopencv_ts240d.lib\
-lopencv_video240d.lib\
-lopencv_videostab240d.lib
我試圖chainging以下FirstProject。親內容,但在所有
#-------------------------------------------------
#
# Project created by QtCreator 2013-04-26T11:15:33
#
#-------------------------------------------------
QT += core
QT -= gui
TARGET = FirstProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\opencv\build\include\
LIBS += -LC:\opencv\build\x86\vc10\lib \
-lopencv_core240 \
-lopencv_highgui240 \
-lopencv_imgproc240 \
-lopencv_features2d240 \
-lopencv_calib3d240
下面沒有好是我的代碼
的main.cpp
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image = imread("D:/Tulips.jpg");
if(!image.data)
{
cout << "Error loading image" << endl;
}
else
{
namedWindow("Image");
imshow("Image",image);
}
waitKey(0);
return 0;
}
爲什麼會出現這個錯誤?請幫我擺脫這個問題
有趣的是,如果您持有'CTRL'並將鼠標懸停在庫名稱上,則Qt檢測到的成功將導致鼠標變爲手形圖標 – user3079474 2015-04-05 09:04:08