且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何告诉 cmake 我希望我的项目静态链接库?

更新时间:2022-06-14 04:25:26

您只需在 CMake 中将 BUILD_SHARED_LIBS 标志设置为 false 即可构建静态 OpenCV 库.然后,使用这些静态库构建自己的应用程序所需要做的就是在 CMakeLists.txt 中添加对 OpenCV 的依赖:

You build static OpenCV libraries by just setting the BUILD_SHARED_LIBS flag to false in CMake. Then all you need to do to build your own application with those static libraries is to add a dependency on OpenCV in your CMakeLists.txt:

FIND_PACKAGE (OpenCV REQUIRED)
...
TARGET_LINK_LIBRARIES (your-application ${OpenCV_LIBS})

CMake 会处理一切.

and CMake will take care of everything.