Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenCV with Qt used within a Qt Creator project with vs2012 compiler [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    plaxik
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        plaxik
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            plaxik
            wrote on last edited by
            #5

            Awesome!

            Thx :)

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved