Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] Cannot link libs statically
Forum Updated to NodeBB v4.3 + New Features

[Solved] Cannot link libs statically

Scheduled Pinned Locked Moved Installation and Deployment
24 Posts 2 Posters 11.8k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Looks fine

    Can you show the exact compilation errors you have ?

    On a side note, you can use the unix notation in the pro files even on Windows

    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
    • L Offline
      L Offline
      liimyd
      wrote on last edited by
      #5

      There's 17 errors, one for each of the OpenCV libaries that I try to link. They're all the same except for the name of the lib. Here's just the first one:

      C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lopencv_calib3d300

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

        Did you check the compiler output panel to see what you have as -L parameters ?

        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
        • L Offline
          L Offline
          liimyd
          wrote on last edited by
          #7

          Sorry for the slow reply! It was a busy week for school.

          This is what my compiler output says right before I get the errors, I'm not too sure what you mean by the -L parameters, is this it?

          g++ -static -static-libgcc -Wl,-s -Wl,-subsystem,windows -mthreads -o release\blood_visual.exe release/main.o release/mainwindow.o release/contours.o release/edge.o release/blood_visual_plugin_import.o release/moc_mainwindow.o release/moc_contours.o release/moc_edge.o -lmingw32 -LC:/Qt/Static/5.3/lib -lqtmain -LC:\Programs\opencvMinGW\install\x64\mingw\bin -lopencv_calib3d300 -lopencv_core300 -lopencv_features2d300 -lopencv_flann300 -lopencv_highgui300 -lopencv_imgcodecs300 -lopencv_imgproc300 -lopencv_ml300 -lopencv_objdetect300 -lopencv_photo300 -lopencv_shape300 -lopencv_stitching300 -lopencv_superres300 -lopencv_video300 -lopencv_videoio300 -lopencv_videostab300 -LC:/Qt/Static/5.3/plugins/accessible -lqtaccessiblewidgets -lQt5Widgets -LC:/Qt/Static/5.3/plugins/platforms -lqwindows -lwinspool -lshlwapi -lQt5PlatformSupport -LC:/Qt/Static/5.3/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm -lglu32 -lopengl32 -lgdi32 -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32

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

            -L is used to give the linker additional folders to search for libraries. It seems that you didn't add the folder where the OpenCV libraries are located.

            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
            • L Offline
              L Offline
              liimyd
              wrote on last edited by
              #9

              I'm slightly confused. From one of my previous posts above, didn't I correctly link the OpenCV folder containing the libraries in my .pro file? Or was I supposed to do it another way?

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

                Where is opencv_calib3d300.lib located on your computer ?

                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
                • L Offline
                  L Offline
                  liimyd
                  wrote on last edited by
                  #11

                  They're all in C:\Programs\opencvMinGW\install\x64\mingw\bin, which was made with CMake.

                  Perhaps I'm using the wrong types of libraries? All of the openCV files in that folder have a format like "libopencv_calib3d300.dll", for instance. Maybe I'm not supposed to be using .dll files? It works fine with my other kit though.

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

                    You don't link to dlls you link to lib files, where are these located ?

                    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
                    • L Offline
                      L Offline
                      liimyd
                      wrote on last edited by
                      #13

                      Ahhhhhhhh I see... :(
                      Yes, those should be in C:\Programs\opencv\build\x86\vc12\staticlib

                      Now I know why the folder was called "staticlib"... I will try this later! Thank you!!

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

                        Not so fast ! Since you have dlls you probably have a second set of these in another folder. On Windows, the static libraries and the import libraries have the same extension...

                        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
                        • L Offline
                          L Offline
                          liimyd
                          wrote on last edited by
                          #15

                          I can't find another folder containing the libs (neither in the original opencv folders, nor in the folders created by CMake), and as you predicted, the libraries in staticlib didn't work. Where can I go from here?

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

                            I just realized: C:\Programs\opencv\build\x86\vc12\staticlib
                            That means that these libs are for Visual Studio not MinGW

                            Unless you built OpenCV yourself, just grab the archive again

                            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
                            • L Offline
                              L Offline
                              liimyd
                              wrote on last edited by
                              #17

                              Sorry, I don't quite understand. After I re-downloaded the package for opencv 3.0, I only had files with a .lib extension in the staticlib folder, which you already said not to use, and in C:\Programs\opencv\build\x86\vc12\lib, which only has opencv_ts300 and opencv_world300 (I don't know how to use these). I can't seem to find any other .lib files.

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

                                Then where did you get the dlls from ?

                                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
                                • L Offline
                                  L Offline
                                  liimyd
                                  wrote on last edited by
                                  #19

                                  The dlls were created with cmake, but I couldn't find the regular libraries from the cmake-generated folders. Do I have to rebuild opencv with cmake? I was using the cmake-gui and there were a lot of different options that I could check or uncheck. Maybe some of them will build the regular libraries?

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

                                    If the dlls were created with cmake then you already built it by hand so you should have the corresponding lib files somewhere

                                    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
                                    • L Offline
                                      L Offline
                                      liimyd
                                      wrote on last edited by liimyd
                                      #21

                                      I rebuilt opencv, this time with BUILD_SHARED_LIBS = Off, which made .a files.
                                      I read that .a files are the same as .lib files.
                                      My .pro file now looks like this:

                                      INCLUDEPATH += C:\\Programs\\opencvMinGW5\\install\\include
                                      
                                      LIBS += -LC:\\Programs\\opencvMinGW5\\install\\x64\\mingw\\staticlib \
                                      -lopencv_core300 \
                                      -lopencv_highgui300 \
                                      -lopencv_imgcodecs300 \
                                      -lopencv_imgproc300 \
                                      -lzlib \
                                      -lIlmImf
                                      

                                      I have a few compilation errors, and I wasn't able to google them, do you know what they mean?

                                      g++ -static -static-libgcc -Wl,-s -Wl,-subsystem,windows -mthreads -o release\blood_visual.exe release/main.o release/mainwindow.o release/contours.o release/edge.o release/blood_visual_plugin_import.o release/moc_mainwindow.o release/moc_contours.o release/moc_edge.o -lmingw32 -LC:/Qt/Static/5.3/lib -lqtmain -LC:\Programs\opencvMinGW5\install\x64\mingw\staticlib -lopencv_core300 -lopencv_highgui300 -lopencv_imgcodecs300 -lopencv_imgproc300 -lzlib -lIlmImf -LC:/Qt/Static/5.3/plugins/accessible -lqtaccessiblewidgets -lQt5Widgets -LC:/Qt/Static/5.3/plugins/platforms -lqwindows -lwinspool -lshlwapi -lQt5PlatformSupport -LC:/Qt/Static/5.3/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm -lglu32 -lopengl32 -lgdi32 -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32

                                      C:\Programs\opencvMinGW5\install\x64\mingw\staticlib\libopencv_highgui300.a(window_w32.cpp.obj):window_w32.cpp:(.text$ZL17icvCreateTrackbarPKcS0_PiiPFviEPFviPvES4+0x62f): undefined reference to `_imp__CreateToolbarEx@52'

                                      C:\Programs\opencvMinGW5\install\x64\mingw\staticlib\libopencv_imgproc300.a(imgwarp.cpp.obj):imgwarp.cpp:(.text$cvLogPolar+0x68b): undefined reference to `cvCartToPolar'

                                      C:\Programs\opencvMinGW5\install\x64\mingw\staticlib\libopencv_imgproc300.a(imgwarp.cpp.obj):imgwarp.cpp:(.text$cvLogPolar+0x6c9): undefined reference to `cvLog'

                                      C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: C:\Programs\opencvMinGW5\install\x64\mingw\staticlib\libopencv_imgproc300.a(imgwarp.cpp.obj): bad reloc address 0x6c9 in section `.text$cvLogPolar'

                                      I think I might be missing some static libs or maybe the order I'm listing the libs is wrong.

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

                                        There's something not clear, I see MinGW5 in your OpenCV path and Qt uses 4.9.1, which one did you use to build 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
                                        • L Offline
                                          L Offline
                                          liimyd
                                          wrote on last edited by liimyd
                                          #23

                                          OpenCVMinGW5 is just the name of the folder for my Cmake files (my sad 5th attempt at building OpenCV). I used 4.9.1 to build. Sorry for the confusion.

                                          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