OpenCV 作为静态库(cmake 选项)
我想在嵌入式系统中使用 OpenCV 库,并且需要使用 OpenCV 作为静态库来编译我的项目。
如何使用 cmake 选项创建库?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要将 OpenCV 构建为静态库,您需要将 BUILD_SHARED_LIBS 标志设置为 false/off:
但我认为这对于您的任务来说还不够,因为您实际上需要为您的架构交叉编译库。如果是 Android 或 IOS,这样的端口已经存在,您可以简单地使用它。如果是其他平台,您需要创建自己的 cmake 工具链文件以进行交叉编译,并可能在 OpenCV 构建系统中进行一些修复。
To build OpenCV as static library you need to set
BUILD_SHARED_LIBS
flag to false/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.
BUILD_SHARED_LIBS=OFF
cmake 选项将创建静态库。应该注意的是,在撰写本文时,OpenCV 并不真正支持静态构建,因为安装在某个地方时结果将无法使用。
https://github.com/opencv/opencv/issues/21447#issuecomment- 1013088996
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