OpenCV with Qt used within a Qt Creator project with vs2012 compiler [SOLVED]



  • Hi,

    my project consists of two parts:

    • OpenCV 2.4.8 built with the following configurations: static lib, dynamic crt, with qt (changed the cmakelist.txt of highgui module such that mac processor is run); vs2012 compiler is used

    • Qt Creator project which includes the built opencv include-headers and staticlibs; vs2012 compiler is used to build a .dll

    it's just a console application. no gui and no widgets are needed within the code. I only build openCV wit Qt support in order to use qt-fonts and to tackle the limited ascii character set of OpenCV (just the standard ascii character set is supported).

    However, as soon as I try to use cv::fontQt() with the setup described above, I get the following errors within Qt Creator:

    bq. opencv_highgui248d.lib(window_QT.obj):-1: Error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QCursor::QCursor(enum Qt::CursorShape)" (_imp [...]

    There are 420 of them and each is almost of the same type. Only the part after the "public:" changes.

    My .pro-File looks as follows:

    @QT -= gui

    TARGET = DicomServices
    TEMPLATE = lib

    DEFINES += DICOMSERVICES_LIBRARY
    DEFINES += NOMINMAX

    SOURCES += DicomNode.cpp
    [...]
    HEADERS += DicomNode.h
    [...]

    win32:LIBS += -L$$PWD/../../MergeTK/mc3lib/ -lws2_32
    win32:LIBS += -L$$PWD/../../MergeTK/mc3lib/ -lmc3adv
    win32:LIBS += -L$$PWD/../../MergeTK/mc3lib/ -lpicnm

    CONFIG( debug, debug|release ) {
    #debug
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_core248d
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_highgui248d
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_imgproc248d
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_features2d248d
    #3d party
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lzlibd
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibjpegd
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibtiffd
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibpngd
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lIlmImfd
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibjasperd
    } else {
    #release
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_core248
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_highgui248
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_imgproc248
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lopencv_features2d248
    #3d party
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lzlib
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibjpeg
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibtiff
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibpng
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -lIlmImf
    win32:LIBS += -L$$PWD/../../OpenCV/staticlib/ -llibjasper
    }

    INCLUDEPATH += $$PWD/../../MergeTK/mc3inc
    DEPENDPATH += $$PWD/../../MergeTK/mc3inc
    INCLUDEPATH += $$PWD/../../OpenCV/include
    DEPENDPATH += $$PWD/../../OpenCV/include@

    Edit:

    • I included all other opencv-libs: still 420 errors
    • However, when I add the following to the .pro file, there is just one error messsage left:

    @QT += widgets@

    bq. opencv_highgui248d.lib(window_QT.obj):-1: Error: LNK2019: unresolved external symbol "__declspec(dllimport) char __cdecl QTest::keyToAscii(enum Qt::Key)" (_imp[...]

    Has anybody made similar experiences and know how to get rid of all these error messages?
    Is there another solution to 'remove' the 420 error messages than turning "widget" on?

    I appreciate any kind of help!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    No, it's the right solution, since you are linking to highgui, you'll need the widgets module.

    For the last error, you are missing the test module.



  • Ah, great. Thanks for the advice. All errors are gone :)


  • Lifetime Qt Champion

    You're welcome !

    One other thing you can do:

    @
    SUFFIX=
    win32 {
    LIBS += -L$$PWD/../../OpenCV/staticlib/
    CONFIG(debug, debug|release): SUFFIX=d
    }

    LIBS+= -lopencv_core248$$SUFFIX
    -lopencv_highgui248$$SUFFIX
    etc.
    @

    It'll make your pro file easier to read



  • Awesome!

    Thx :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.