after successfully building the opencv library (4.5.3) with java bindings (
BUILD_SHARED_LIBS=OFF; BUILD_FAT_JAVA_LIB=ON) via mingw64 under windows 10, inspecting its dependencies I found some mingw64-specific libraries (libgcc, libstdc++, libwinpthread):
For distribution purposes, I would prefer to statically link those mingw64-specific dependencies inside my custom-built opencv library, so I tried to apply the following linkage flags (for example to
CMAKE_EXE_LINKER_FLAGS), without success:
-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic
How can I instruct cmake to apply those flags?
i dont think, you can do this.
while the windows/system32 will be available on all win machines,
the mingw64 dlls have to be copied along with your binaries.
(downside of using mingw instead of vs …)
oh, and if you want video, youll also need to redistribute opencv_videoio_ffmpeg_64.dll
I’m wondering what supposedly makes impossible to statically link mingw libraries into the opencv library…
(Side note – I’m building a custom opencv library precisely because I need to strip its video modules away: a well-known dependency issue affecting the precompiled opencv library for Windows arose when a user installed my application (a still-image processor) on Windows Server 2012 R2, so it’s convenient for me to remove that functionality.)
legal stuff (licenses).
you aren’t building “a custom library”. you’d merely build some modules of opencv. if you don’t need
videoio, deselect that in cmake-gui (or set the corresponding variable).
because there are no statically built mingw libs for this. (eg no static c runtime)