CMake RelWithDebInfo链接到调试库 [英] CMake RelWithDebInfo links to Debug libs

查看:566
本文介绍了CMake RelWithDebInfo链接到调试库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目链接到六个库,其中包括OpenCV.
由于Release版本崩溃了,而Debug运行良好(慢了很多),所以我想用RelWithDebInfo配置编译我的项目.
但是,包含了Debug版本的OpenCV库而不是Release(OpenCV没有RelWithDebInfo变体).这会导致链接错误,例如:

I have a project which links to half a dozen libraries, among them OpenCV.
Since Release variant is crashing, while Debug is working fine (just a lot slower), I wanted to compile my project in RelWithDebInfo configuration.
However, Debug version of OpenCV libraries gets included instead of Release (OpenCV doesn’t have RelWithDebInfo variant). This causes linking errors such as:

opencv_core249d.lib(alloc.obj):错误LNK2038:检测到"RuntimeLibrary"不匹配:值"MDd_DynamicDebug"与MyProject.obj中的值"MD_DynamicRelease"不匹配

opencv_core249d.lib(alloc.obj) : error LNK2038: mismatch detected for ‘RuntimeLibrary’: value ‘MDd_DynamicDebug’ doesn’t match value ‘MD_DynamicRelease’ in MyProject.obj

如何解决这个问题?

推荐答案

解决方案:在调用FIND_PACKAGE(OpenCV)后添加到CMakeLists.txt:

Solution: add to CMakeLists.txt, after the call to FIND_PACKAGE(OpenCV):

set_target_properties(${OpenCV_LIBS} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE)

这篇关于CMake RelWithDebInfo链接到调试库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆