无法添加定义以提升构建 [英] Unable to add defines to boost build

查看:26
本文介绍了无法添加定义以提升构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 boost buildsystem 构建 boost 序列化/文件系统/系统的调试版本.这是我使用的:

I am trying to build a debug build of boost serialization/filesystem/system using boost buildsystem. Here is what I use:

  b2 serialization filesystem system variant=debug link=static threading=multi
  runtimelink=static define=_HAS_ITERATOR_DEBUGGING=0 toolset=msvc-11.0

但是,当我在调试 Visual Studio 项目中包含该库时,我仍然会遇到如下错误:

However, when I include the library in my debug visual studio projects I still get errors like this:

(basic_iarchive.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Game.obj

这让我相信我在 boost 版本中的定义"没有任何效果.什么是正确的语法?我找不到任何示例,文档也没有说明其他任何内容.

Which leads me to belive that my 'define' in the boost build did not have any effect. What is the proper syntax? I cannot find any examples, and the documentation dosnt say anything else on the matter.

我想强制要求在我的 boost 构建中定义 _HAS_ITERATOR_DEBUGGING=0

I would like to enforce that I want to define _HAS_ITERATOR_DEBUGGING=0 in my boost build

推荐答案

_ITERATOR_DEBUG_LEVEL 不是 boost 的东西,而是 MSVC 附带的标准库实现的一部分.您必须非常小心地使用此设置的一致值编译构建中的所有内容.在许多情况下,链接器会像您引用的消息一样诊断违规,但不幸的是,它可能未被发现.由于它改变了大多数 std 集合和相关内容的大小和布局,猜猜接下来会发生什么.

_ITERATOR_DEBUG_LEVEL is not boost's thing but part of standard library implementation that ships with MSVC. You must take greatest care to compile everything in your build with a consistent value of this setting. In many cases a violation it's diagnosed by the linker like the message you quote, unfortunately it can go undetected. As it changes the size and layout of most std collections and related stuff, guess what follows.

默认情况下,它没有设置为任何内容,当您包含一些标准头文件时,它会查找 _DEBUG 并将其自身设置为 2.如果系统中没有设置它并且您始终使用 _DEBUG,那么好方法.

By default it is not set to anything, and when you include some standard header it looks for _DEBUG and sets itself to 2. Good way if nothing in the system ever sets it and you consistently use _DEBUG.

使用 boost 我不熟悉,但我猜你引用的设置会强制值为 0 的宏.如果是这样,难怪你有差异.将其设置为 2,或者如果您的意思是 0,请继续并在您的所有项目中使用它.

With boost I'm not familiar, but would guess the setting you quote would force the macro with value 0. If so, no wonder you have a discrepancy. Set it to 2, or if you mean 0, go ahead and use that in all your projects.

这篇关于无法添加定义以提升构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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