0

I have a static build for both Qt and OpenCV. When I try to make a static application in QtCreator:

g++ -static -static-libgcc -Wl,-s -Wl,-subsystem,windows -mthreads -o release\Test.exe release/main.o release/mainview.o release/opencvcam.o release/thing.o release/test_plugin_import.o release/moc_mainview.o release/moc_opencvcam.o  -lmingw32 -LC:/Qt/Static/5.3.1/lib -lqtmain -LC:/Programs/Opencv_static_build/lib -LC:/Programs/Opencv_static_build/3rdparty/lib -lzlib -llibjasper -llibjpeg -llibpng -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -LC:/Qt/Static/5.3.1/plugins/accessible -lqtaccessiblewidgets -lQt5Widgets -LC:/Qt/Static/5.3.1/plugins/platforms -lqwindows -lwinspool -lshlwapi -lQt5PlatformSupport -LC:/Qt/Static/5.3.1/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 

I get the following error:

C:/Programs/Opencv_static_build/lib\libopencv_core249.a(persistence.cpp.obj):persistence.cpp:(.text$_ZL12icvCloseFileP13CvFileStorage+0x4e): undefined reference to gzclose' C:/Programs/Opencv_static_build/lib\libopencv_core249.a(persistence.cpp.obj):persistence.cpp:(.text$_ZL6icvEofP13CvFileStorage+0x43): undefined reference togzeof'

I tried reordering the third party libs, but I don't know how they need to be ordered in the first place.

My goal here is to build standalone app with Qt and OpenCV. However, if that's not possible given my current knowledge, I would need to find another way. If I copy all the DLLs into the .exe direcory, is this going to work on another Windows machine? I don't have another Windows PC here, so don't know how to test right now.

Thank you!

Slav
  • 25
  • 7
  • Can you build a minimal static linked code with only opencv and one with only qt? – Micka Dec 02 '14 at 17:25
  • I can build static application with Qt only. Just tried making a static C++ console application with OpenCV and got the same error again. – Slav Dec 02 '14 at 17:52
  • Did you check your opencv staticlib folder whether there some more libs you can add? – Micka Dec 02 '14 at 17:59
  • There are a lot of libraries in that folder, but I am not using them. I tried compiling a static application with declaring just `cv::Mat` and using only `libopencv_core249.a`, but the result is the same. I also included all the third party libs in the project. Please take a look here: [link](http://stackoverflow.com/questions/15588906/problems-with-opencv-compilation-with-static-linking-on-pandaboard), which describes a problem similar to mine. The functions that the build can't find are in `zlib`, which is also included (at the first place in the list). – Slav Dec 02 '14 at 18:06
  • Simple main function that only declares cv::Mat needs opencv_core and zlib libs for me (order doesnt matter). But using VS2010 build environment atm... – Micka Dec 02 '14 at 18:31
  • Not working for me in QtCreator, unfortunately. – Slav Dec 02 '14 at 20:06
  • Did you build the static libs with same settings? About your 2nd question: normally its enough to just copy all the dlls but better test it somehow – Micka Dec 02 '14 at 20:36
  • OpenCV is built with BUILD_SHARED_LIBS off, BUILD_PNG=ON BUILD_JASPER=ON BUILD_JPEG=ON BUILD_ZLIB=ON WITH_JPEG=ON WITH_PNG=ON. For Qt I used a script that I downloaded from Qt Centre. – Slav Dec 02 '14 at 20:47

0 Answers0