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. <SOLVED>Program only works if .DLL extension is left off
Forum Updated to NodeBB v4.3 + New Features

<SOLVED>Program only works if .DLL extension is left off

Scheduled Pinned Locked Moved General and Desktop
opencv qt dll
9 Posts 4 Posters 2.7k Views 2 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.
  • TechnologistT Offline
    TechnologistT Offline
    Technologist
    wrote on last edited by Technologist
    #1

    Have built a simple OpenCV program to display a photo. It only works if I leave the .dll extensions** off **of its Library listing in the pro. file:
    Won't run:
    LIBS += -LC:\\OpenCV-2.3.1\\bin\ -lopencv_core2411.dll \ -lopencv_highgui2411.dll \ -lopencv_imgproc2411.dll \ -lopencv_features2d2411.dll \ -lopencv_calib3d2411.dll
    Will execute:
    LIBS += -LC:\\OpenCV-2.3.1\\bin\ -lopencv_core2411\ -lopencv_highgui2411\ -lopencv_imgproc2411 \ -lopencv_features2d2411 \ -lopencv_calib3d2411
    Adding to the oddity, a few of these DLL files have only partial names that work.
    For example DLL: opencv_imgproc2411 still links the file without the lib in front of the opencv...libopencv_imgproc2411

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by
      #2

      Linkage where LIBS are used require *.lib ( extension is added automatically ) files not dlls.

      *.lib files are either statically linked libraries or interface to appropriate dll which resolves calls to exported functions.

      dlls are needed only during execution of application.

      1 Reply Last reply
      0
      • TechnologistT Offline
        TechnologistT Offline
        Technologist
        wrote on last edited by
        #3

        Ok, that seems logical. Why is it working anyway with a path to the dlls. Since there are no lib files there shouldn't it throw an error...or does it treat the dll file as a lib one since there is no dll extension?

        K 1 Reply Last reply
        0
        • TechnologistT Technologist

          Ok, that seems logical. Why is it working anyway with a path to the dlls. Since there are no lib files there shouldn't it throw an error...or does it treat the dll file as a lib one since there is no dll extension?

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @Technologist
          No. There is definitely a difference between dll and lib. Not everywhere the extension .lib is used. MinGW uses .a

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • TechnologistT Offline
            TechnologistT Offline
            Technologist
            wrote on last edited by
            #5

            Ok! I found the library files *.dll.a and included them in the build. I specified the files themselves. I posted the correct code below, one pro file in unix and win.

            correct unix
            QT       += core
            
            QT       -= gui
            
            TARGET = untitled17a
            CONFIG   += console
            CONFIG   -= app_bundle
            
            TEMPLATE = app
            
            SOURCES += main.cpp \
            
            INCLUDEPATH += C:/OpenCV-2.3.1/install/include
            LIBS += -LC:/OpenCV-2.3.1/lib/ -llibopencv_core2411.dll.a (Unix)
            LIBS += C:/OpenCV-2.3.1/lib/  libopencv_highgui2411.dll.a (win32)
            
            
            HEADERS += \
                heas.h
            

            If I had 20 library files how would I handle that? Import library through QT Creator?

            1 Reply Last reply
            0
            • TechnologistT Offline
              TechnologistT Offline
              Technologist
              wrote on last edited by Technologist
              #6

              I thought I had it until I tried a test using a bogus extension...:(

              LIBS += -LC:/OpenCV-2.3.1/lib/ -llibopencv_core2411.dll.x

              Besides I only have 2 directories dll and dll.a

              Built just fine, a bad good thing.

              Executable runs fine outside of qt.

              K 1 Reply Last reply
              0
              • TechnologistT Technologist

                I thought I had it until I tried a test using a bogus extension...:(

                LIBS += -LC:/OpenCV-2.3.1/lib/ -llibopencv_core2411.dll.x

                Besides I only have 2 directories dll and dll.a

                Built just fine, a bad good thing.

                Executable runs fine outside of qt.

                K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                @Technologist
                That it is not running with Qt creator framework might be an issue with size. However, I have no experience with opencv.

                When you use external dlls, respectively dlls in general, you link stubs, much smaller libs, to your code. The stubs have all information for using the dlls lateron. With the naming and which libs to link to your code you need to check with opencv. With MinGW you can rename the libs and sometimes people do this. This is in contrast to MS where the libs are always called *.lib as far as I collect.

                Another thing you are refering to the complete path to libs in one string. That is possble on Windows. However, in case you migrate lateron to Linux or MacOS you need to use the separate notation. It might be helpful to get used to it directly. Checkout LIBS parameter. There is also a summary on third party libs.

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • TechnologistT Offline
                  TechnologistT Offline
                  Technologist
                  wrote on last edited by
                  #8

                  I think I misstated myself --

                  LIBS += -LC:/OpenCV-2.3.1/lib/ -llibopencv_core2411.dll.x
                  

                  The .x extension was a test for a false positive: the library executed successfully with a madeup .x extension.

                  It is just confusing. I'm trying to make sure everything is running ok.

                  Additionally, I think it sage advice to build cross platform compatibility starting now. I have studied the link above, and it mentions windows and Unix. Where do I get information about coding the other platforms in qmake?

                  Overall, based on what you are saying, the .pro file can manage the compatibilties but you only have to write one program - that's the beauty of Qt?

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

                    Hi,

                    Basically you should have something like:

                    win32:LIBS += -LC:/OpenCV-2.3.1/lib/
                    LIBS += -lopencv_core2411
                    

                    And that should be enough, win32 will scope the line so it'll only get executed for windows target. You can then add scopes for your other target OS to setup the correct path to OpenCV

                    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

                    • Login

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