PDA

View Full Version : Can't build OpenCV example using Qt



AlexanderPD
8th November 2012, 14:59
Hi, this is my first attempt with Qt, i failed some installation tries but with the Nokia SDK installer everything worked fine :)

I successfully installed OpenCV 2.4.2 and they run well with visual studio 2010, but now i want to try developing with Qt. I made a very simple example code:


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

int main() {

cv::Mat image= cv::imread("img.jpg");
cv::namedWindow("My Image");
cv::imshow("My Image",image);
cv::waitKey(5000);

return 1;
}


but i have tons of error while building :(

here the full console output


15:50:04: Running build steps for project prova1...
15:50:04: Configuration unchanged, skipping qmake step.
15:50:04: Starting: "C:\QtSDK\QtCreator\bin\jom.exe"
c:\qtsdk\desktop\qt\4.8.1\msvc2010\bin\qmake.exe -spec ..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\mkspec s\win32-msvc2010 CONFIG+=declarative_debug -o Makefile ..\prova1\prova1.pro
Qt: Untested Windows version 6.2 detected!

jom 1.0.6 - empower your cores

Qt: Untested Windows version 6.2 detected!
WARNING: c:\Users\Valerio\Downloads\prova1\prova1.pro:38: Unescaped backslashes are deprecated.
WARNING: c:\Users\Valerio\Downloads\prova1\prova1.pro:38: Unescaped backslashes are deprecated.
WARNING: c:\Users\Valerio\Downloads\prova1\prova1.pro:38: Unescaped backslashes are deprecated.
C:\QtSDK\QtCreator\bin\jom.exe -nologo -j 2 -f Makefile.Debug
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\includ e\QtCore" -I"..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\includ e" -I"..\..\..\..\OpenCV2.4.2\build\include" -I"LIBS" -I"+=" -I"-LC:\OpenCV2.4.2\build\x64\mingw\lib" -I"-llibopencv_calib3d242.dll.a" -I"-llibopencv_contrib242.dll.a" -I"-llibopencv_core242.dll.a" -I"-llibopencv_features2d242.dll.a" -I"-llibopencv_flann242.dll.a" -I"-llibopencv_gpu242.dll.a" -I"-llibopencv_highgui242.dll.a" -I"-llibopencv_imgproc242.dll.a" -I"-llibopencv_legacy242.dll.a" -I"-llibopencv_ml242.dll.a" -I"-llibopencv_nonfree242.dll.a" -I"-llibopencv_objdetect242.dll.a" -I"-llibopencv_photo242.dll.a" -I"-llibopencv_stitching242.dll.a" -I"-llibopencv_ts242.a" -I"-llibopencv_video242.dll.a" -I"-llibopencv_videostab242.dll.a" -I"..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\includ e\ActiveQt" -I"debug" -I"..\prova1" -I"." -I"..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\mkspec s\win32-msvc2010" -Fodebug\ @C:\Users\Valerio\AppData\Local\Temp\main.obj.5572 .0.jom
Qt: Untested Windows version 6.2 detected!
main.cpp
link /LIBPATH:"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:CONSOLE "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST /MANIFESTFILE:"debug\prova1.intermediate.manifest" /OUT:debug\prova1.exe @C:\Users\Valerio\AppData\Local\Temp\prova1.exe.55 72.1422.jom
main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function _main
main.obj : 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 &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@ D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z) referenced in function _main
main.obj : 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)" (?namedWindow@cv@@YAXABV?$basic_string@DU?$char_tr aits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
main.obj : 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)" (?imread@cv@@YA?AVMat@1@ABV?$basic_string@DU?$char _traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ)
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ)
debug\prova1.exe : fatal error LNK1120: 7 unresolved externals
command failed with exit code 1120
command failed with exit code 2
15:50:06: The process "C:\QtSDK\QtCreator\bin\jom.exe" exited with code 2.
Error while building project prova1 (target: Desktop)
When executing build step 'Make'

and.. this is my prova1.pro:


#-------------------------------------------------
#
# Project created by QtCreator 2012-11-08T14:21:20
#
#-------------------------------------------------

QT += core

QT -= gui

TARGET = prova1
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app


SOURCES += main.cpp

INCLUDEPATH += C:\OpenCV2.4.2\build\include\
LIBS += -LC:\OpenCV2.4.2\build\x64\mingw\lib \
-llibopencv_calib3d242.dll.a \
-llibopencv_contrib242.dll.a \
-llibopencv_core242.dll.a \
-llibopencv_features2d242.dll.a \
-llibopencv_flann242.dll.a \
-llibopencv_gpu242.dll.a \
-llibopencv_highgui242.dll.a \
-llibopencv_imgproc242.dll.a \
-llibopencv_legacy242.dll.a \
-llibopencv_ml242.dll.a \
-llibopencv_nonfree242.dll.a \
-llibopencv_objdetect242.dll.a \
-llibopencv_photo242.dll.a \
-llibopencv_stitching242.dll.a \
-llibopencv_ts242.a \
-llibopencv_video242.dll.a \
-llibopencv_videostab242.dll.a


i'm using Windows 8 but i don't think this can be a great problem..
Qt Creator version: 2.4.1
Qt for Desktop version 4.8.1

i even tried using this in prova1.pro:

LIBS += -C:\OpenCV2.4.2\build\x86\vc10\lib\*.lib
and LOT of other tries.. but always with this or other errors :(

what i'm doing wrong?

ferdna
13th October 2013, 02:16
remove "lib" and ".dll.a" from the library name.

ex:
-llibopencv_calib3d242.dll.a
to
-lopencv_calib3d242