[Solved] Cannot link libs statically
-
I just realized: C:\Programs\opencv\build\x86\vc12\staticlib
That means that these libs are for Visual Studio not MinGWUnless you built OpenCV yourself, just grab the archive again
-
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.
-
Then where did you get the dlls from ?
-
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?
-
If the dlls were created with cmake then you already built it by hand so you should have the corresponding lib files somewhere
-
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.
-
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 ?