连接Visual Studio 2008的前preSS'/ MTD“设置时升压崩溃 [英] Boost crash when linking Visual Studio 2008 Express '/Mtd' setting
问题描述
链接我的新鲜刺激建立与Visual Studio(/ MTD)原因助推进入main函数之前抛出bad_alloc例外。
Linking my fresh boost build with Visual Studio (/Mtd) causes boost to throw a 'bad_alloc' exception before entering the main function.
我建立了使用说明Boost库从入门说明。建立prerequisites后,我用下面的构建命令:
I built the boost library using the instructions from the Getting Started instructions. After setting up the prerequisites I used the following build command:
bjam -j8 --build-dir="C:\Development\Boost\boost-build" --build-type=complete msvc stage
上面的命令似乎构建调试/发布的所有组合和共享/静态生成。
Above command seems to build all combinations of debug/release and shared/static builds.
然后,我创建了一个空的Visual Studio项目,并添加主文件中的以下code:
Then I created a empty Visual Studio project and added the following code in the main file:
#include <boost/thread.hpp>
int main()
{
return 0;
}
我也改变了code代设置,多线程调试(/ MTD)。
I also changed the Code Generation settings to Multi-threaded Debug (/MTd).
在这一点上,我还没有配置在我的项目的库路径。因此,建立一个与下面的链接器出错而结束:
At this point I did not yet configure any library paths in my project. So the build ended with the following linker error:
LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc90-mt-sgd-1_43.lib'
好吧,我发现在我的提振构建这个文件,并将其复制到$(SolutionDir)的3rdParty \\ Boost_1_43_0 \\库'这是我加入附加库目录。下一个错误如下:
LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc90-mt-sgd-1_43.lib'
好吧,我也觉得我的提振build目录此文件,并将其复制到我的库路径。
Ok, I also find this file in my boost build directory and copy it to my library path.
在此之后,项目构建成功地,而是一个'bad_alloc抛出异常升压code,在进入main函数之前。
After this the project builds succesfully, but a 'bad_alloc" exception is thrown in boost code, before entering the main function.
似乎有一个图书馆不兼容在这里。有谁知道究竟是怎么了,怎么解决?
It seems that there is a library incompatibility here. Does anyone know what exactly is going wrong, and how to fix it?
由于詹姆斯McNellis 中提到的,这可能是特定的线程库我尝试了program_options'的东西,这一个不引起任何问题(主体仍然是空的虽然)。
Since James McNellis mentioned that this may be something specific to the thread library I tried out 'program_options' and this one doesn't cause any problems (main body is still empty though).
使用升压'信号'库一个简单的示例应用程序工作正常也。所以,它真的是造成一些问题线程库。
A simple sample application using the boost 'signal' library works fine also. So it's really the thread library that's causing some problem.
我目前使用升压v1.43.0,我会看看我是否能与V1.42重现该问题。
I'm currently using Boost v1.43.0, I'll see if I can reproduce the problem with v1.42.
有一个细节我想提一提的是,我使用升压的精简版。我使用创建一个子集以下 BCP 工具:
One detail I'd like to mention is that I am using a stripped down version of Boost. I created a subset using the following bcp utility:
mkdir ./output
bcp bind function lexical_cast noncopyable optional program_options smart_ptr signals signals2 thread ./output
这可能不是导致bad_alloc虽然...
This probably isn't causing the 'bad_alloc' though...
我只是用 BoostPro Installe ř安装升压1.42。快速测试显示,它工作正常,像这样。奇怪...
I just installed Boost 1.42 using the BoostPro Installer. A quick test revealed that it works fine like this. Strange...
推荐答案
我的<击>解决方案击>云的解决方法如下:
My solution workaround goes as follows:
- 使用安装提振 BoostPro安装。它安装提振C:\\ Program Files文件。目录
- 使用(含)BCP实用程序来创建升压库的精简下来的副本。见我原来的职位的例子。
- 生成的头添加到我的项目文件夹
- 同样任何需要的库复制到项目文件夹。
- 更新的Visual Studio项目包括和链接器的路径需要的地方。
- 测试它。
- 这一切承诺SVN。
- 瞧,我知道有我的电池,包括code库:)
- Install boost using the BoostPro Installer. It installs Boost in the 'C:\Program Files' directory.
- Use the (included) bcp utility to create a slimmed down copy of the boost repository. See my original post for an example.
- Add the generated headers to my project folder
- Also copy any needed libs to the project folder.
- Update the Visual Studio projects include and linker paths where needed.
- Test it.
- Commit it all to SVN.
- Voila, I know have my batteries-included code repository :)
其实,我原来的问题仍然没有答案,但我仍然不知道为什么我对升压1.43尝试失败。这也可能是一些配置问题。然而,这是一个令人满意的解决办法。
Actually, my original question remains unanswered, I still don't know why my attempts for Boost 1.43 failed. It's probably some configuration issue. However, this is a satisfying workaround.
顺便说一句,我为什么收归提升1.42的原因很简单,因为BoostPro安装程序还不支持1.43。
By the way, the reason why I reverted to Boost 1.42 is simply because the BoostPro Installer does not yet support 1.43.
这篇关于连接Visual Studio 2008的前preSS'/ MTD“设置时升压崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!