PDA

View Full Version : Mixing static and dynamic libraries using Qt Creator



xsades
13th February 2015, 11:47
I have a static Qt build. I am trying to use openCV shared libraries with statically linked Qt and standart c libraries. I couldn'yt figure how to do that.

Here is my .pro file10952


If i compile this code: 10953

resulting .exe works correctly without asking any .dlls.

But if i use openCV library and compile this code:

10954

resulting .exe asks for both "libopencv_core2410.dll" and other standart libraries like "libgcc_s_dw2-1.dll"

What i want is make it ask only for opencv shared libraries. Any help will be appreciated. Sorry for my bad English. :)

wysota
13th February 2015, 15:43
You can't do that unless you compile the c++ runtime from MinGW statically into the opencv dll. Which is probably out of scope of this forum.

xsades
13th February 2015, 20:08
Thanks! I've compiled opencv statically and problem was solved.

Sashabn
21st June 2015, 01:01
Hi, can you explain how you static compile opencv for qt. In cmake when i set BUILD_SHARED_LIBS=off i got this error Make Error at apps/haartraining/CMakeLists.txt:37 (add_library):
Target "opencv_haartraining_engine" links to itself.
And then in vs when i compile opencv i got lot of this errors:

Error 45 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QMutex::QMutex(enum QMutex::RecursionMode)" (__imp_??0QMutex@@QAE@W4RecursionMode@0@@Z) referenced in function "void __cdecl `dynamic initializer for 'mutexKey''(void)" (??__EmutexKey@@YAXXZ) C:\ocv\myocv\apps\annotation\opencv_highgui2411.li b(window_QT.obj) opencv_annotation
I use staticly compile Qt 5.4.1 with mingw32 and opencv 2.4.
Thanks for any help