在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

本文关键字:libboost regex-vc120-mt-sgd-1 li studio visual 构建      更新时间:2023-10-16

问题

我正在学习boost库,以便将来在windows上的x64控制台应用程序中使用。我尝试了这里提供的最简单的例子:

http://www.boost.org/doc/libs/1_59_0/more/getting_started/windows.html#prepare-使用增强型二元

我希望构建的boost库满足以下条件:

  1. 用于x64平台。我的控制台应用程序是处理三维数据,所以x64是必须的
  2. 可以在visualstudio中以调试模式和发布模式使用
  3. 构建为静态库。我的控制台应用程序需要在另一台计算机上运行
  4. 可以在多线程中使用。我需要多线程使我的程序尽可能快

我阅读了该网页的说明,搜索了许多其他页面,并尝试了许多构建命令,如:

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,要么我需要以某种方式设置项目属性。

我的问题

  1. 如何在发布模式下成功构建小型项目
  2. 在构建助推时,b2和bjam之间有什么区别

您不希望将版本构建链接到LIBCMTD。