构建C++通过CMAKE与OpenCV和DLIB库的项目

发布于 2025-01-26 00:18:36 字数 925 浏览 2 评论 0原文

我将C ++项目与OpenCV和DLIB库一起使用。我有cmakelists.txt:

cmake_minimum_required(VERSION 3.20.0)

project(project1)

find_package(OpenCV REQUIRED)

include(FetchContent)
FetchContent_Declare(dlib
    GIT_REPOSITORY https://github.com/davisking/dlib.git
    GIT_TAG        v19.18
)
FetchContent_MakeAvailable(dlib)

add_executable(project1 main.cpp)
target_link_libraries(project1 ${OpenCV_LIBS} dlib::dlib)
target_compile_options(project1 PUBLIC "$<$<CONFIG:RELEASE>:${MY_RELEASE_OPTIONS}>") 

我在cygwin cmake中写作.. -g“ unix makefiles”。我使用“ Unix Makefiles”来创建用于命令“ make”的makefile。在此之后,我写了制作,但是结果我会出现错误:

collect2: error: ld execution ended with return code 1
make[2]: *** [CMakeFiles/project1.dir/build.make:123: project1.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:115: CMakeFiles/project1.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

解决此问题需要做什么?

I use c++ project with opencv and dlib libraries. I have CMakeLists.txt:

cmake_minimum_required(VERSION 3.20.0)

project(project1)

find_package(OpenCV REQUIRED)

include(FetchContent)
FetchContent_Declare(dlib
    GIT_REPOSITORY https://github.com/davisking/dlib.git
    GIT_TAG        v19.18
)
FetchContent_MakeAvailable(dlib)

add_executable(project1 main.cpp)
target_link_libraries(project1 ${OpenCV_LIBS} dlib::dlib)
target_compile_options(project1 PUBLIC "
lt;
lt;CONFIG:RELEASE>:${MY_RELEASE_OPTIONS}>") 

I write in cygwin cmake .. -G "Unix Makefiles". I use "Unix Makefiles" to create makefile that use to command "make". After this I write make, but as a result I get error:

collect2: error: ld execution ended with return code 1
make[2]: *** [CMakeFiles/project1.dir/build.make:123: project1.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:115: CMakeFiles/project1.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

What I need to do to fix this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文