Results 1 to 7 of 7

Thread: OpenCV 2.1 + Qt 4.6 on WindowsXP

  1. #1
    Join Date
    Nov 2007
    Posts
    6
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default OpenCV 2.1 + Qt 4.6 on WindowsXP

    Hi,

    I have been trying all day to get a very simple OpenCV based program to compile. I tried on a Mac with OpenCV installed from source, all work as expected and the program is able to load and process an image provided. However, I am having a ton of difficulties to even get it to compile on WindowsXP, let alone run it!

    I have searched Google and this forum for all the possible resolutions, but they all failed. I tried using the reimp, dlltool and pexports tools to convert the pre-compiled DLLs and LIBs from OpenCV and tried to link it. The compiler will not compile at all, but keep spitting out 2 errors:

    1. undefined reference to OpenCV's methods and functions; or
    2. ld.exe cannot find the *.a file even it is there.

    These were what I did:

    1. undefined reference

    a. I use the reimp tool to generate a *.def and *.a file from the supplied LIB files downloaded from OpenCV's website.

    b. I updated the pro file with

    INCLUDEPATH += "C:/OpenCV2.1-1/include/opencv"

    win32:LIBS += "C:\OpenCV2.1-1\lib\libcv210.a" \
    "C:\OpenCV2.1-1\lib\libcvaux210.a" \
    "C:\OpenCV2.1-1\lib\libcxcore210.a" \
    "C:\OpenCV2.1-1\lib\libhighgui210.a" \

    The error I got:

    Qt Code:
    1. debug/main.o: In function `main':
    2. C:\cygwin\home\kwong13\opencv_test1/main.cpp:36: undefined reference to `cv::namedWindow(std::string const&, int)'
    3. C:\cygwin\home\kwong13\opencv_test1/main.cpp:51: undefined reference to `cv::imshow(std::string const&, cv::Mat const&)'
    4. C:\cygwin\home\kwong13\opencv_test1/main.cpp:55: undefined reference to `cv::waitKey(int)'
    5. debug/main.o:C:\cygwin\home\kwong13\opencv_test1/../../../../OpenCV2.1/include/opencv/cxmat.hpp:378: undefined reference to `cv::fastFree(void*)'
    6. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    I have also tried following the MinGW tutorial on how to convert VC++ LIBs to MinGW's *.a. To no avail.



    2. ld.exe cannot find the library even the file is there

    a. I changed the pro file to

    INCLUDEPATH += "C:/OpenCV2.1-1/include/opencv"

    win32:LIBS += -l"C:\OpenCV2.1-1\lib\libcv210.a" \
    -l"C:\OpenCV2.1-1\lib\libcvaux210.a" \
    -l"C:\OpenCV2.1-1\lib\libcxcore210.a" \
    -l"C:\OpenCV2.1-1\lib\libhighgui210.a"

    And I get the following error:

    Qt Code:
    1. g++ -static -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\opencv_test1.exe debug/main.o -L"c:\Qt\2010.02.1\qt\lib" -lC:\OpenCV2.1-1\lib\libcv210.a -lC:\OpenCV2.1-1\lib\libcvaux210.a -lC:\OpenCV2.1-1\lib\libcxcore210.a -lC:\OpenCV2.1-1\lib\libhighgui210.a -lQtGuid4 -lQtCored4
    2. mingw32-make[1]: Leaving directory `C:/cygwin/home/myhome/opencv_test1'
    3. mingw32-make: Leaving directory `C:/cygwin/home/myhome/opencv_test1'
    4. c:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lC:\OpenCV2.1-1\lib\libcv210.a
    5. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    I have also tried with this entry in the pro file:

    win32:LIBS += -L"C:/OpenCV2.1-1/lib" -lcv210 -lhighgui210 -lcxcore210
    Same error.


    Perhaps is there anyone had successfully got this working?

    I did find one or two forum threads stating they got it working. However, they never share how they did it, and the entry date was quite old. Thus, I assume they have no intention of sharing their success.

    Please, can someone, anyone, please help me! I am really stuck with this for the passed 8 hours. I do not want to compile OpenCV on WindowsXP as I am afraid it will break my another app that uses OpenCV through Java.

    Please help!

  2. #2
    Join Date
    Nov 2007
    Posts
    6
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: OpenCV 2.1 + Qt 4.6 on WindowsXP

    Problem solved!

    I inevitably have to compile OpenCV 2.1 myself using MinGW to get it working.

    I found another thread, not here, that redirected me to download TDM-GCC (http://tdm-gcc.tdragon.net/download), and abandoned the original MinGW. The reason is OpenCV 2.1 needs GCC 4.4.0 and above. The original MinGW comes with GCC 3.8.x. This can compile only up to maybe 40% of the framework and gives out errors.

    So, what I did was:

    1. Download and install CMake 2.8
    2. Download and install MinGW by TDM.
    3. Set a PATH to TDM MinGW's bin folder, if it is not set.
    4. Generate the Makefiles needed using CMake by choosing MinGW option when asked.
    5. Launch cmd, go to OpenCV's directory and type "mingw-make" or "mingw32-make".

    After step 5, the DLLs will be placed in the bin/ folder and the *.dll.a files will be placed in the lib/ folder.

    6. Update my PRO file with:

    Qt Code:
    1. LIBS += "C:\OpenCV2.1\lib\libcv210.dll.a" \
    2. "C:\OpenCV2.1\lib\libcvaux210.dll.a" \
    3. "C:\OpenCV2.1\lib\libcxcore210.dll.a" \
    4. "C:\OpenCV2.1\lib\libhighgui210.dll.a"
    To copy to clipboard, switch view to plain text mode 

    7. Build my OpenCV code and done. The build should work.

    8. Copy the DLL files from the OpenCV2.1/bin folder to the debug/ or release/ folders, depends on the build mode, and run the code.

    The copying is needed because I did not set a PATH to OpenCV and I plan to distribute my Qt apps with the DLLs. If you think this is troublesome, you will need to set a path to those DLLs.

    9. You are done!


    NOTE: As of this writing, somehow the methods found in highgui module is bugged. I cannot get it to display a window properly. However, I think this is not a too big of an issue as I can always display images as QImage, and I found a lot of tutorials and forum threads on how to do this in Qt. Hopefully the OpenCV developers fix the problem.

  3. The following 2 users say thank you to pamalite for this useful post:

    gmiller39 (16th July 2010), PeterPaulAndMary (26th July 2010)

  4. #3
    Join Date
    Dec 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Maemo/MeeGo

    Default Re: OpenCV 2.1 + Qt 4.6 on WindowsXP

    Quote Originally Posted by pamalite View Post
    Problem solved!

    I inevitably have to compile OpenCV 2.1 myself using MinGW to get it working.

    I found another thread, not here, that redirected me to download TDM-GCC (http://tdm-gcc.tdragon.net/download), and abandoned the original MinGW. The reason is OpenCV 2.1 needs GCC 4.4.0 and above. The original MinGW comes with GCC 3.8.x. This can compile only up to maybe 40% of the framework and gives out errors.

    So, what I did was:

    1. Download and install CMake 2.8
    2. Download and install MinGW by TDM.
    3. Set a PATH to TDM MinGW's bin folder, if it is not set.
    4. Generate the Makefiles needed using CMake by choosing MinGW option when asked.
    5. Launch cmd, go to OpenCV's directory and type "mingw-make" or "mingw32-make".

    After step 5, the DLLs will be placed in the bin/ folder and the *.dll.a files will be placed in the lib/ folder.

    6. Update my PRO file with:

    Qt Code:
    1. LIBS += "C:\OpenCV2.1\lib\libcv210.dll.a" \
    2. "C:\OpenCV2.1\lib\libcvaux210.dll.a" \
    3. "C:\OpenCV2.1\lib\libcxcore210.dll.a" \
    4. "C:\OpenCV2.1\lib\libhighgui210.dll.a"
    To copy to clipboard, switch view to plain text mode 

    7. Build my OpenCV code and done. The build should work.

    8. Copy the DLL files from the OpenCV2.1/bin folder to the debug/ or release/ folders, depends on the build mode, and run the code.

    The copying is needed because I did not set a PATH to OpenCV and I plan to distribute my Qt apps with the DLLs. If you think this is troublesome, you will need to set a path to those DLLs.

    9. You are done!


    NOTE: As of this writing, somehow the methods found in highgui module is bugged. I cannot get it to display a window properly. However, I think this is not a too big of an issue as I can always display images as QImage, and I found a lot of tutorials and forum threads on how to do this in Qt. Hopefully the OpenCV developers fix the problem.
    Hi, I am very new to QT, and OpenCV. But I want to learn both, and I like to develop an Image Processing Application. I have installed Qt 4.6 and OpenCV 2.2. I opened a new GUI application in Qt and Simply paste the following code as main.cpp.
    #include <QtGui/QApplication>
    #include "mainwindow.h"
    #include <QtGui>
    #include<cv.h>
    #include<highgui.h>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    //MainWindow w;
    //w.show();
    cvNamedWindow( "My Window", 1 );
    IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
    CvFont font;
    double hScale = 1.0;
    double vScale = 1.0;
    int lineWidth = 1;
    cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
    hScale, vScale, 0, lineWidth );
    cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
    cvScalar( 255, 255, 0 ) );
    cvShowImage( "My Window", img );
    cvWaitKey();
    return a.exec();
    }
    Then did edit the .PRO file for INCLUDEPATH and LIBS as
    INCLUDEPATH += C:\OpenCV2.2\include C:\OpenCV2.2\include\opencv
    LIBS += C:\OpenCV2.2\lib\*.lib.

    I didn't get any error message during build. But when I tried to run the program, I got the following error message Starting
    C:\Qt\Examples\NewTest-build-desktop\debug\NewTest.exe...
    C:\Qt\Examples\NewTest-build-desktop\debug\NewTest.exe exited with code -1073741510. I might be wrong. But your help will make me a quick start. Can anyone tell me, where did I went wrong...............

  5. #4
    Join Date
    Jan 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV 2.1 + Qt 4.6 on WindowsXP

    gopakkumarg.....I've tried your code and it's work but you must edit in your project *.pro on line:

    Qt Code:
    1. LIBS += C:\OpenCV2.2\lib\*.lib.
    To copy to clipboard, switch view to plain text mode 

    change to

    Qt Code:
    1. LIBS += C:\OpenCV2.2\bin\*.dll
    To copy to clipboard, switch view to plain text mode 

    here the result after i run it.



    I use Qt 4.7, OpenCV 2.2 compiled in Mingw on windows7 OS.
    May be this can help you..

  6. #5
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default OpenCV 2.2 + Qt 4.7 on Windows don't work!!!

    I have the same problem with opencv 2.2 . Don't Work . Help me please!!

    Captura.PNG

  7. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: OpenCV 2.1 + Qt 4.6 on WindowsXP

    I didn't get any error message during build. But when I tried to run the program, I got the following error message Starting
    I've had the same problem today.
    Compiled OpenCV 2.2 on Windows XP ( g++ 4.5.2 ), everything is great until I run my program - everytime an OpenCV method is called, the app crashes.
    Launched with gdb - crash was in void cv::cvt_( CvMat *, CvMat * ) everytime.

    I have fixed this by recompiling OpenCV with SSE support disabled.
    So, if you can build your app with OpenCV 2.2, but can't run it, try to recompile OpenCV without SSE / SSE2 support.

    I've found this suggestion here: link
    I've used CMake, so I've only un-checked SSE / SSE2 options (instead of modifying CMakeList.txt file manually).

  8. #7
    Join Date
    Jan 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV 2.1 + Qt 4.6 on WindowsXP

    Hi,

    is it possible to use
    Qt Code:
    1. double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
    To copy to clipboard, switch view to plain text mode 
    with your setup when you capture a video from a webcam?

    This is not possible to use too:
    Qt Code:
    1. cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
    2. cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 240);
    To copy to clipboard, switch view to plain text mode 

    I only get fps = 0.0 on windows xp, opencv 2.2 and qt4.7

Similar Threads

  1. Marble as Qt Designer Plugin on WindowsXP
    By peirenjun in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 13:43
  2. Instalation and Setting Qt4 on WindowsXP
    By frenk_castle in forum Installation and Deployment
    Replies: 3
    Last Post: 1st September 2009, 13:12
  3. Makefile moc path corrupted in WindowsXP Qt 4.4.2
    By khopper in forum Qt Programming
    Replies: 4
    Last Post: 27th September 2008, 22:49
  4. WindowsXP Style?
    By CaseMillennium in forum Newbie
    Replies: 5
    Last Post: 23rd June 2007, 19:13
  5. WindowsXP : menu items activated() doesn't work
    By Valheru in forum Qt Programming
    Replies: 2
    Last Post: 10th October 2006, 13:21

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.