PDA

View Full Version : Static Linking Qt with openCV



harvey_slash
15th December 2013, 17:00
I just downloaded openCV and built it using cmake, making sure to uncheck 'build sharedlibs' option.
I want to build an exe that has all the dlls required for openCV to work .
after writing a code, unless I put the opencv core dll in the same folder as my application , the application doesn't work.
also , none of the highgui functions seem to work.
what am I doing wrong ?

my .pro file :

QT += core

QT -= gui
LIBS += -Wl,-Bstatic -Wl,-Bdynamic
TARGET = untitled4
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app
CONFIG += -static -static-libgcc

SOURCES += main.cpp
INCLUDEPATH +=C:\opencv\install\include

LIBS+= G:\opencv\build\x86\vc11\bin\bin\libopencv_core247 .dll
LIBS+= G:\opencv\build\x86\vc11\bin\bin\libopencv_highgui 247.dll

RESOURCES += \
test.qrc



I tried static building option in cmake, and changing the name from .dll to .a, but its always the same problem .

I am using a static version of Qt
I followed this tutorial :
http://stackoverflow.com/questions/15881913/how-to-link-opencv-in-qtcreator-and-use-qt-library

ChrisW67
15th December 2013, 20:04
You are currently explicitly telling the linker to use the dynamic link library for the two OpenCV libraries so it is unsurprising that you get that. If you use the *.a file and still get linked to the DLLs then you have a dynamic library build of OpenCV.

Check for differently named static versions of the libraries, or diagnose why you are not getting a static build of OpenCV. If you previously had a dynamic build and did not completely clean it out when switching to staic then that would be a likely factor.

harvey_slash
16th December 2013, 12:09
I am using Cmake, how do I make a static build of openCv?
I tried unchecking the option 'build shared libs' in cmake gui, but it didn't seem to help

EDIT:
in the build folder, I can see a folder called staticlib, is that the folder to use ?
its full of .pdb and .lib files

ChrisW67
16th December 2013, 21:48
I cannot tell you from first hand experience. I do not have a statically built OpenCV and do not propose building one just to find out.

http://stackoverflow.com/questions/7583172/opencv-as-a-static-library-cmake-options

If you are using GCC the the *.lib files are almost certainly not the result of your build. They are likely to be suitable for use with Microsoft's compiler.

harvey_slash
17th December 2013, 08:36
That didn't work .


okay, first error :
libgcc_s_sjlj-1.dll missing

libstdc++-6.dll missing
libgcc_s_dw2-1 missing

after I add all these dlls , I get






The procedure entry point -ZNSt8_setail15_List_node_base7_M_hookEPS0_ could not be located in the dynamic link library D:\Test\libopencv_highgui247.dll