I want to use OpenCV library in an embedded system and I need to compile my project using OpenCV as a static library.
How can I create the library using cmake options ?
I want to use OpenCV library in an embedded system and I need to compile my project using OpenCV as a static library.
How can I create the library using cmake options ?
To build OpenCV as static library you need to set BUILD_SHARED_LIBS
flag to false/off:
cmake -DBUILD_SHARED_LIBS=OFF ..
But I think it is not enough for your task because you actually need to cross-compile library for you architecture. In case of Android or IOS such port already exists and you can simply use it. In case of another platform you need to create your own cmake toolchain file for cross-compiling and probably make a number of fixes in OpenCV build system.
ccmake .
== ./configure --help
–
Looby -DBUILD_SHARED_LIBS=OFF
creates the dynamic files too? –
Spicer // Build shared libraries (.dll/.so) instead of static ones (.lib/.a) BUILD_SHARED_LIBS:BOOL=ON
–
Compose BUILD_SHARED_LIBS
only makes OpenCV's own libs into static ones, but does nothing about its (transitive) dependencies like GStreamer. You'd need to build static libraries of all dependencies and somehow ensure that the OpenCV build system uses them... it might not be trivial. –
Indocile The BUILD_SHARED_LIBS=OFF
cmake option will create static libraries.
It should be noted that at the time of writing this, OpenCV does not really support static build, in that the result will not be useable when installed somewhere.
https://github.com/opencv/opencv/issues/21447#issuecomment-1013088996
© 2022 - 2024 — McMap. All rights reserved.
-DCMAKE_CXX_COMPILER=i586-mingw32msvc-g++
? I see CMake's advantages over autotools, but what's CMake's equivalent of./configure --help
? – Deirdre