Results 1 to 2 of 2

Thread: Can't build OpenCV example using Qt

  1. #1
    Join Date
    Nov 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Can't build OpenCV example using Qt

    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:

    Qt Code:
    1. #include <opencv2/core/core.hpp>
    2. #include <opencv2/highgui/highgui.hpp>
    3.  
    4. int main() {
    5.  
    6. cv::Mat image= cv::imread("img.jpg");
    7. cv::namedWindow("My Image");
    8. cv::imshow("My Image",image);
    9. cv::waitKey(5000);
    10.  
    11. return 1;
    12. }
    To copy to clipboard, switch view to plain text mode 

    but i have tons of error while building

    here the full console output

    Qt Code:
    1. 15:50:04: Running build steps for project prova1...
    2. 15:50:04: Configuration unchanged, skipping qmake step.
    3. 15:50:04: Starting: "C:\QtSDK\QtCreator\bin\jom.exe"
    4. c:\qtsdk\desktop\qt\4.8.1\msvc2010\bin\qmake.exe -spec ..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\mkspecs\win32-msvc2010 CONFIG+=declarative_debug -o Makefile ..\prova1\prova1.pro
    5. Qt: Untested Windows version 6.2 detected!
    6.  
    7. jom 1.0.6 - empower your cores
    8.  
    9. Qt: Untested Windows version 6.2 detected!
    10. WARNING: c:\Users\Valerio\Downloads\prova1\prova1.pro:38: Unescaped backslashes are deprecated.
    11. WARNING: c:\Users\Valerio\Downloads\prova1\prova1.pro:38: Unescaped backslashes are deprecated.
    12. WARNING: c:\Users\Valerio\Downloads\prova1\prova1.pro:38: Unescaped backslashes are deprecated.
    13. C:\QtSDK\QtCreator\bin\jom.exe -nologo -j 2 -f Makefile.Debug
    14. 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\include\QtCore" -I"..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\include" -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\include\ActiveQt" -I"debug" -I"..\prova1" -I"." -I"..\..\..\..\QtSDK\Desktop\Qt\4.8.1\msvc2010\mkspecs\win32-msvc2010" -Fodebug\ @C:\Users\Valerio\AppData\Local\Temp\main.obj.5572.0.jom
    15. Qt: Untested Windows version 6.2 detected!
    16. main.cpp
    17. 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.5572.1422.jom
    18. main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function _main
    19. 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
    20. 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
    21. 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_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
    22. 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
    23. 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)
    24. 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)
    25. debug\prova1.exe : fatal error LNK1120: 7 unresolved externals
    26. command failed with exit code 1120
    27. command failed with exit code 2
    28. 15:50:06: The process "C:\QtSDK\QtCreator\bin\jom.exe" exited with code 2.
    29. Error while building project prova1 (target: Desktop)
    30. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    and.. this is my prova1.pro:

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2012-11-08T14:21:20
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core
    8.  
    9. QT -= gui
    10.  
    11. TARGET = prova1
    12. CONFIG += console
    13. CONFIG -= app_bundle
    14.  
    15. TEMPLATE = app
    16.  
    17.  
    18. SOURCES += main.cpp
    19.  
    20. INCLUDEPATH += C:\OpenCV2.4.2\build\include\
    21. LIBS += -LC:\OpenCV2.4.2\build\x64\mingw\lib \
    22. -llibopencv_calib3d242.dll.a \
    23. -llibopencv_contrib242.dll.a \
    24. -llibopencv_core242.dll.a \
    25. -llibopencv_features2d242.dll.a \
    26. -llibopencv_flann242.dll.a \
    27. -llibopencv_gpu242.dll.a \
    28. -llibopencv_highgui242.dll.a \
    29. -llibopencv_imgproc242.dll.a \
    30. -llibopencv_legacy242.dll.a \
    31. -llibopencv_ml242.dll.a \
    32. -llibopencv_nonfree242.dll.a \
    33. -llibopencv_objdetect242.dll.a \
    34. -llibopencv_photo242.dll.a \
    35. -llibopencv_stitching242.dll.a \
    36. -llibopencv_ts242.a \
    37. -llibopencv_video242.dll.a \
    38. -llibopencv_videostab242.dll.a
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. LIBS += -C:\OpenCV2.4.2\build\x86\vc10\lib\*.lib
    To copy to clipboard, switch view to plain text mode 
    and LOT of other tries.. but always with this or other errors

    what i'm doing wrong?

  2. #2
    Join Date
    Oct 2009
    Location
    Texas
    Posts
    15
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Can't build OpenCV example using Qt

    remove "lib" and ".dll.a" from the library name.

    ex:
    -llibopencv_calib3d242.dll.a
    to
    -lopencv_calib3d242

Similar Threads

  1. Replies: 2
    Last Post: 3rd October 2011, 23:04
  2. Trying to use OpenCV
    By danilodsp in forum Newbie
    Replies: 6
    Last Post: 18th August 2011, 08:41
  3. Failed to build Qt 4.7.1 in a shadow build with feature tuning
    By myfifth in forum Installation and Deployment
    Replies: 0
    Last Post: 17th February 2011, 03:25
  4. Replies: 1
    Last Post: 13th January 2010, 23:35
  5. Moving from QT 4.5 shared build to QT 4.5.2 static build
    By extrakun in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2009, 09:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.