Results 1 to 12 of 12

Thread: Couldn't link opencv with qt creator , this error happens

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2014
    Posts
    15
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Couldn't link opencv with qt creator , this error happens

    Hello,

    I've been trying to solve this since yesterday with no luck,

    first I downloaded the latest version of opencv , it came with it two folders , one is source and one is build I assumed build folder is the precompiled folder which is what I want, anyways I did this in the pro file:

    Qt Code:
    1. INCLUDEPATH += C:/opencv/build/include
    2. LIBS +=-LC:/opencv/build/x86/vc11/staticlib
    3. CONFIG(debug, debug|release){
    4. LIBS +=-lopencv_core249\
    5. LIBS +=-lopencv_core249d\
    6. LIBS +=-lopencv_highgui249\
    7. LIBS +=-lopencv_highgui249d\
    8. }
    To copy to clipboard, switch view to plain text mode 

    and it gives me this error:

    Qt Code:
    1. :-1: error: LNK1104: cannot open file '+=-lopencv_core249d.obj'
    To copy to clipboard, switch view to plain text mode 

    when I delete
    LIBS +=-lopencv_core249d\

    it gives me the same error except it's for the highgui249d file.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Couldn't link opencv with qt creator , this error happens

    The -l lib name option needs to be on the same line as the -L so you need a \, and also the debug/release are not supposed to be linked together, so the syntax should become something like:
    Qt Code:
    1. CONFIG( debug, debug|release ) {
    2. #debug libs
    3. LIBS +=-LC:/opencv/build/x86/vc11/staticlib\
    4. -lopencv_core246d\
    5. -lopencv_highgui246d
    6. }
    7. else {
    8. #release libs
    9. LIBS +=-LC:/opencv/build/x86/vc11/staticlib\
    10. -lopencv_core246\
    11. -lopencv_highgui246
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Zlatomir; 2nd May 2014 at 19:42.

  3. The following user says thank you to Zlatomir for this useful post:

    Being friendzoned sucks (2nd May 2014)

  4. #3
    Join Date
    Mar 2014
    Posts
    15
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Couldn't link opencv with qt creator , this error happens

    Quote Originally Posted by Zlatomir View Post
    The -l lib name option needs to be on the same line as the -L so you need a \, and also the debug/release are not supposed to be linked together, so the syntax should become something like:
    Qt Code:
    1. CONFIG( debug, debug|release ) {
    2. #debug libs
    3. LIBS += -LLIBS +=-LC:/opencv/build/x86/vc11/staticlib\
    4. -lopencv_core246d\
    5. -lopencv_highgui246d
    6. }
    7. else {
    8. #release libs
    9. LIBS += -LLIBS +=-LC:/opencv/build/x86/vc11/staticlib\
    10. -lopencv_core246\
    11. -lopencv_highgui246
    12. }
    To copy to clipboard, switch view to plain text mode 
    well thanks buddy , now I have a new problem:

    LNK1181: cannot open input file 'opencv_core246.lib'

    when I compile in release mode and when I compile in debug mode it shows the same problem except for the debug file:

    LNK1181: cannot open input file 'opencv_core246d.lib'

  5. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Couldn't link opencv with qt creator , this error happens

    My bad, sorry, some copy/paste errors, i corrected the error in my previous post, and also you seem to have the 2.49 version of opencv (you can check the file names in that lib folder), so the code becomes:
    Qt Code:
    1. CONFIG( debug, debug|release ) {
    2. #debug libs
    3. LIBS +=-LC:/opencv/build/x86/vc11/staticlib\
    4. -lopencv_core249d\
    5. -lopencv_highgui249d
    6. }
    7. else {
    8. #release libs
    9. LIBS +=-LC:/opencv/build/x86/vc11/staticlib\
    10. -lopencv_core249\
    11. -lopencv_highgui249
    12. }
    To copy to clipboard, switch view to plain text mode 

    LE: don't forget to run qmake after you modify the .pro file.

  6. The following user says thank you to Zlatomir for this useful post:

    Being friendzoned sucks (2nd May 2014)

  7. #5
    Join Date
    Mar 2014
    Posts
    15
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Couldn't link opencv with qt creator , this error happens

    Yeah I fixed the copy thing before using it

    but I'm stupid enough to forget about changing the names to the new version names..

    anyways they're still some problems

    first I added these to my pro file:

    Qt Code:
    1. INCLUDEPATH += C:/opencv249/build/include/
    2. CONFIG( debug, debug|release ) {
    3. #debug libs
    4. LIBS +=-LC:/opencv249/build/x64/vc11/staticlib\
    5. -lopencv_core249d\
    6. -lopencv_highgui249d
    7. }
    8. else {
    9. #release libs
    10. LIBS +=-LC:/opencv249/build/x64/vc11/staticlib\
    11. -lopencv_core249\
    12. -lopencv_highgui249
    13. }
    To copy to clipboard, switch view to plain text mode 

    second here is the includes + code

    Qt Code:
    1. #include<opencv/cv.h>
    2. #include<opencv/highgui.h>
    3.  
    4. void MainWindow::showimage1(){
    5. IplImage*img=cvLoadImage("C:\\Users\\myuser\\QT\\build-CaptureTools-Unnamed-Debug\\Fri May 2 2014_3039.png");
    6. cvNamedWindow("example",CV_WINDOW_AUTOSIZE);
    7. cvShowImage("example",img);
    8. cvWaitKey(0);
    9. cvReleaseImage(&img);
    10. cvDestroyWindow("example");
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 
    ------------------------------------------

    first I'll start with the notifications that it shows in the issues section along with the errors:

    Qt Code:
    1. C:\opencv249\build\include\opencv2\flann\logger.h:66: warning: C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    2.  
    3. C:\opencv249\build\include\opencv2\flann\logger.h:66: warning: C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    4.  
    5. C:\opencv249\build\include\opencv2\flann\logger.h:66: warning: C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    To copy to clipboard, switch view to plain text mode 


    -----------------------------------------------------

    the errors:

    Qt Code:
    1. mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvReleaseImage referenced in function "public: void __thiscall MainWindow::showimage1(void)" (?showimage1@MainWindow@@QAEXXZ)
    2.  
    3. mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvNamedWindow referenced in function "public: void __thiscall MainWindow::showimage1(void)" (?showimage1@MainWindow@@QAEXXZ)
    4.  
    5. mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvShowImage referenced in function "public: void __thiscall MainWindow::showimage1(void)" (?showimage1@MainWindow@@QAEXXZ)
    6.  
    7. mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvDestroyWindow referenced in function "public: void __thiscall MainWindow::showimage1(void)" (?showimage1@MainWindow@@QAEXXZ)
    8.  
    9. mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvLoadImage referenced in function "public: void __thiscall MainWindow::showimage1(void)" (?showimage1@MainWindow@@QAEXXZ)
    10.  
    11. mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvWaitKey referenced in function "public: void __thiscall MainWindow::showimage1(void)" (?showimage1@MainWindow@@QAEXXZ)
    12.  
    13. debug\CaptureTools.exe:-1: error: LNK1120: 6 unresolved externals
    To copy to clipboard, switch view to plain text mode 

  8. #6
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Couldn't link opencv with qt creator , this error happens

    Are you trying to build using the same compiler as opencv version? (from the opencv path is seems to be vc11, that means Visual Studio 2012)

  9. The following user says thank you to Zlatomir for this useful post:

    Being friendzoned sucks (2nd May 2014)

Similar Threads

  1. Qt Creator 5.0.1 and OpenCv 2.4.3 mingw x86
    By marcocadei in forum Installation and Deployment
    Replies: 11
    Last Post: 16th February 2013, 20:20
  2. OpenCV integration with Qt creator
    By mind_freak in forum Qt Programming
    Replies: 11
    Last Post: 8th January 2013, 22:50
  3. Qt Creator and OpenCV , .dll missing
    By schludy in forum Newbie
    Replies: 0
    Last Post: 30th November 2011, 10:11
  4. Problem with openCV compilation in Qt Creator
    By mind_freak in forum Qt Programming
    Replies: 2
    Last Post: 22nd February 2011, 12:26
  5. Using OpenCV with QT creator
    By gmiller39 in forum Newbie
    Replies: 3
    Last Post: 7th July 2010, 15:32

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.