如何在 CMake Makefile 中包含 OpenCV 库
我希望你能帮助我。
我有一个简单的 CMakeLists.txt,以便在 Leopard 10.5.8 上构建我的项目。 我正在使用 CMake 2.8.1,目前这是代码:
cmake_minimum_required(VERSION 2.8)
MESSAGE(STATUS "./src: Going into utils folder")
ADD_SUBDIRECTORY(utils)
MESSAGE(STATUS "./src: utils folder processed")
include_directories(${DIR}/headers)
link_directories (${DIR}/src/utils)
ADD_EXECUTABLE(sample sample.cpp)
TARGET_LINK_LIBRARIES(sample libSample ${EXTERNAL_LIBS})
INSTALL(TARGETS sample DESTINATION "./src")
MESSAGE(STATUS "./src: exiting src folder")
我需要在我的项目中添加 OpenCV 库。 当我使用 Eclipse 时,我将包含路径设置为 /opt/local/include 以及库路径:/opt/local/lib,然后指定库名称,例如_opencv_core、opencv_imgproc、opencv_video。
您能告诉我如何在 CMakeLists.txt 文件中添加这些信息吗?
我已阅读官方 cmake FAQ 中的一些信息,但无法解决我的问题。
请帮我。
多谢。
I hope you can help me.
I have a simple CMakeLists.txt in order to build my project on Leopard 10.5.8.
I'm using CMake 2.8.1 and at the moment this is the code:
cmake_minimum_required(VERSION 2.8)
MESSAGE(STATUS "./src: Going into utils folder")
ADD_SUBDIRECTORY(utils)
MESSAGE(STATUS "./src: utils folder processed")
include_directories(${DIR}/headers)
link_directories (${DIR}/src/utils)
ADD_EXECUTABLE(sample sample.cpp)
TARGET_LINK_LIBRARIES(sample libSample ${EXTERNAL_LIBS})
INSTALL(TARGETS sample DESTINATION "./src")
MESSAGE(STATUS "./src: exiting src folder")
I need to add OpenCV libraries on my project.
When I use Eclipse I set the include path to /opt/local/include
and the libraries path to: /opt/local/lib and then I specify the libraries name such as_ opencv_core, opencv_imgproc, opencv_video.
Can you tell me how to add these information in the CMakeLists.txt file, please?
I've read some information in the official cmake FAQ but i wasn't able to solve my problem.
Please, help me.
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 TARGET_LINK_LIBRARIES 命令中添加库名称,但需要添加不带 lib 前缀的库名称。例如:
You need to add the library names in the TARGET_LINK_LIBRARIES command, but you need to add them without the lib prefix. For example: