在visual studio中使用构建的升压库时:libboost_regex-vc120-mt-sgd-1_59.li
When using built boost library in visual studio: libboost_regex-vc120-mt-sgd-1_59.lib(instances.obj) : error LNK2038: mismatch detected
问题
我正在学习boost库,以便将来在windows上的x64控制台应用程序中使用。我尝试了这里提供的最简单的例子:
http://www.boost.org/doc/libs/1_59_0/more/getting_started/windows.html#prepare-使用增强型二元
我希望构建的boost库满足以下条件:
- 用于x64平台。我的控制台应用程序是处理三维数据,所以x64是必须的
- 可以在visualstudio中以调试模式和发布模式使用
- 构建为静态库。我的控制台应用程序需要在另一台计算机上运行
- 可以在多线程中使用。我需要多线程使我的程序尽可能快
我阅读了该网页的说明,搜索了许多其他页面,并尝试了许多构建命令,如:
bjam --build-type=complete toolset=msvc-10.0 threading=multi link=static address-model=64
b2 variant=release --build-type=complete architecture=x86 address-model=64 stage
b2 runtime-link=static variant=release address-model=64
最后,我在x64 |调试模式下成功地构建了小型visual studio项目。然而,当我尝试发布模式时,我会出现以下错误:
1>libboost_regex-vc120-mt-sgd-1_59.lib(instances.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(instances.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(regex.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(regex.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(regex_traits_defaults.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(regex_traits_defaults.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(static_mutex.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(static_mutex.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(w32_regex_traits.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(w32_regex_traits.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(regex_raw_buffer.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libboost_regex-vc120-mt-sgd-1_59.lib(regex_raw_buffer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>libcpmtd.lib(stdthrow.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
1>libcpmtd.lib(stdthrow.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
我的分析
我正在使用Visual Studio 2013。看起来"libboost_regex-vc120-mt-sgd-1_59.lib(regex.obj("中的"sgd"表示它是一个调试库。我搜索了%BOOST_ROOT%\stage\lib。与libboost_regex一样,我有:
"C:Program Filesboostboost_1_59_0stageliblibboost_regex-vc120-s-1_59.lib"
"C:Program Filesboostboost_1_59_0stageliblibboost_regex-vc120-sgd-1_59.lib"
"C:Program Filesboostboost_1_59_0stageliblibboost_regex-vc120-mt-1_59.lib"
"C:Program Filesboostboost_1_59_0stageliblibboost_regex-vc120-mt-s-1_59.lib"
"C:Program Filesboostboost_1_59_0stageliblibboost_regex-vc120-mt-sgd-1_59.lib"
"C:Program Filesboostboost_1_59_0stageliblibboost_regex-vc120-mt-gd-1_59.lib"
我没有为visual studio指定libboost_regex-vc120-mt-sgd-1_59.lib,它是visual studio自动选择的。所以,我认为我要么没有构建真正需要的lib,要么我需要以某种方式设置项目属性。
我的问题
- 如何在发布模式下成功构建小型项目
- 在构建助推时,b2和bjam之间有什么区别
您不希望将版本构建链接到LIBCMTD。
相关文章:
- 此模式的C++RegEx
- C++ std::regex 使用前瞻失败
- 在Linux Mint上使用多个版本的libboost
- std::regex:匹配由数字和空格组成的字符串,并提取数字.如何?
- 如何使用 c++ libboost 运行进程并获取其输出?
- 编译花絮 g++, clang++, 使用 libboost -- g++8 编译失败时 g++7 成功;
- 使用 boost::regex 从目录中获取带有一些正则表达式的文件名称时出现意外输出
- 你能防止 std::regex 在无效表达式上抛出异常吗?
- 使用Regex解析cpp中的字符串并创建映射
- C++:如何用split查找单词?Regex
- 在VC2015U3上,std::regex比boost::regex慢得多
- 是否有更有效的方法来生成日期的REGEX字符串
- 在C++中使用带有regex的捕获组
- 将std::regex设置为静态的好主意吗
- 为什么Regex(c++)需要指数时间
- std::regex and dual ABI
- C++11 std::regex后备选项
- 以不同的方式替换每一项,regex c++
- 使用 boost::regex (c++) 比较两个正则表达式
- Build Boost Regex for Windows VS2013