错误链接Boost库有了Quantlib [英] Error Linking Boost Libraries With Quantlib

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

问题描述

我想使用Boost库来构建Quantlib。

I am trying to build Quantlib using Boost Libraries.

我按照说明<一个href=\"http://stackoverflow.com/questions/2629421/how-to-use-boost-in-visual-studio-2010/2655683#2655683\">here:也是Quantlib网站上。

I followed the instructions here: and also on the Quantlib website.

我下载并解压缩boost_1_57_0到C:\\ Program Files文件

I downloaded and unzipped boost_1_57_0 into C:\program files

然后我使用的Visual Studio 2013或x64原生的提示去升压目录并运行

I then used the Visual Studio 2013 x64 Native prompt to go to the boost directory and ran

bootstrap.bat

然后

b2 --toolset=msvc --build-type=complete architecture=x86 address-model=64 stage

然后我在Visual Studio 2013打开Quantlib_vc12.sln。

Then I opened Quantlib_vc12.sln in Visual Studio 2013.

采摘释放和64,在属性管理器中打开Quantlib,并设置VC ++目录。

Picked "Release" and "x64", opened "Quantlib" in Property Manager and set the VC++ Directories.

在include目录我添加C:\\ PROGRAMM文件\\ boost_1_57_0

In the include directories I added C:\Programm Files\boost_1_57_0

在图书馆目录我添加C:\\ Program Files文件\\ boost_1_57_0 \\阶段\\ lib中

In the Library Directories I added C:\Program Files\boost_1_57_0\stage\lib

然后我就去到解决方案资源管理器,右点击,选择版本。

Then I went to the Solution Explorer and right clicked and chose build.

我得到了一个错误LNK1104

I got one LNK1104 error.

LNK1104: cannot open file 'libboost_unit_test_framework-vc120-mt-1_57.lib

请参阅附截图:

我不知道如何解决这一问题和我真的AP preciate一些帮助。我已经成功地安装了此在使用管理员帐户工作,但无法使用我的用户帐户来访问Quantlib。因为我已经删除,并试图安装ATLEAST 15倍,但它不工作。我很担心,所有这些企图安装可能搞砸别的东西了,像一些注册表(我不知道如何工作的,但我只知道害怕)。请帮忙!谢谢你。

I have no idea how to fix this and I would really appreciate some help. I had successfully installed this at work using an admin account but was not able to access Quantlib using my user account. I have since deleted and attempted installations atleast 15 times but it's not working. I am worried that all these attempts at installing may have messed something else up, like some registry (I have no idea how that works but I only know to be afraid). Please help! Thanks.

更新:仍然得到同样的错误增加BOOST_AUTO_LINK_NOMANGLE定义项目后

UPDATE2:我在屏幕上获取这些信息,同时运行B2建设的推动作用。这是我需要修复错误?

推荐答案

这正是我警告过你关于另一个相关问题/答案。这里发生的事情是,你包括在该quantlib升压头是(通过宏)检测到您使用的MSVC,检测的版本,然后自动连接所需的DLL文件来建立quantlib使用#pragma评论(LIB ... )。因此,即使项目设置下 - > C / C ++ - >链接器没有外部的DLL或者Lib的规定,他们还在被这些杂声明链接

This is exactly what I warned you about in another related question/answer. What's happening here is that the boost headers you are including in this quantlib are (through macros) detecting that you're using MSVC, detecting the version, then automatically linking the required DLL files to build quantlib using #pragma comment(lib....). So even though under Project Settings -> C/C++ -> Linker there are no external DLL's or Lib's specified, they're still being linked by these pragma statements.

所以,当这些宏检测编译器等,他们正在动态生成的自己认为需要的库将在您的系统被命名为一个字符串名称。记住,当你建立提升,您指定的-layout选项。这是你Boost库的命名布局。那么在默认情况下,该布局是这样的:

So when these macros are detecting your compiler and so on, they're dynamically building a string name of what they think the required libraries would be named on your system. Remember when you built boost, you specified the -layout option. This the naming layout of your boost libraries. Well by default, that layout is something like this:

LIB_LIBRARY_NAME_COMPILER_VERSION_SingleOrMultiThreaded_BOOST_VERSION.LIB

LIB_LIBRARY_NAME_COMPILER_VERSION_SingleOrMultiThreaded_BOOST_VERSION.LIB

这实际上是这样的:

libboost_unit_test_framework-VC120-MT-1_57.lib

libboost_unit_test_framework-vc120-mt-1_57.lib

这是助推重整你的库的名称是尽可能描述关于库是如何构建这样,只是在文件名一眼,你知道的。我们做什么-layout =系统告诉Boost构建系统不要裂伤的名字,但根据我们给了布局选项是什么对他们的名字。既然我们选择了布局=系统,升压会来命名我们的图书馆是这样的:

This is boost "mangling" the name of your library to be as descriptive as possible about how the libraries were build so that, just by glancing at the file name, you know. What we do with -layout=system is tell the boost build system NOT to mangle the names, but to name them according to what option we gave to "layout". Since we chose layout=system, boost is going to name our libraries like this:

LIB_LIBRARY_NAME.LIB

LIB_LIBRARY_NAME.LIB

这在实践中会产生:

libboost_unit_test_framework.lib

libboost_unit_test_framework.lib

所以,当我们开始做这个(用MSVC仅会出现这种情况)后,使用升压,这些动态生成的链接报表不给有关RIP或不知道什么 -layout 选项,您构建与提升。他们将尝试使用完全错位的命名格式,这是必需的库链接,为什么你的错误:

So when we start using boost after doing this (with MSVC only does this happen), these dynamically generated linker statements don't give a rip about or know about what -layout option you built boost with. They will attempt to link in required libraries using the fully mangled naming format, which is why you get the error:

无法打开文件'libboost_unit_test_framework-VC120-MT-1_57.lib

cannot open file 'libboost_unit_test_framework-vc120-mt-1_57.lib

..因为你没有一个名为该文件!这就是错位的名字!您有一个名为libboost_unit_test_framework.lib文件。看到不同!所以,你需要告诉这些愚蠢的宏停止重整库名称时,自动链接所需的库。你这样做,加入以下preprocessor定义您的Quantlib项目:

.. because you don't have a file named that! That's the mangled name! You have a file named libboost_unit_test_framework.lib. See the difference! So, you need to tell these stupid macros to stop mangling the library names when auto-linking required libraries. You do that by adding the following preprocessor definition to your Quantlib project:

BOOST_AUTO_LINK_NOMANGLE

BOOST_AUTO_LINK_NOMANGLE

您补充一点,在项目设置 - > C / C ++ - > preprocessor ​​ - > preprocessor定义

You add that in Project Settings -> C/C++ -> Preprocessor -> Preprocessor definitions.

如果您宁愿避免这种头痛,不关心长期和(IMO丑陋)重整的提升确实给图书馆的名称,你可以建立升压忽略-layout选项,它会默认为这种错位的命名约定,你应该不会停滞在这个错误可言了。我个人熄努力保持不错的短/洁净库的名字,但它是所有关于preference。

If you'd rather avoid this headache and don't care about the long and (imo ugly) mangling that boost does to library names, you can build boost omitting the -layout option and it will default to this mangled naming convention, where you shouldn't get stuck on this error at all anymore. I personally put out the effort to keep nice short/clean library names but it's all about preference.

修改结果
既然你有固定NO_MANGLE问题后,同样的错误,那么你得到这个特殊的链接错误的唯一可能的原因是你没有任何文件的链接器抱怨缺少存储在任何提供给连接器的目录

Edit
Since you have the same error after fixing the NO_MANGLE problem, then the only possible reason that you're getting this particular link error is that you do not have whatever file the linker is complaining about missing stored in any of the directories supplied to the linker.

验证您所提供的链接中的文件夹/路径,并验证连接器是要找的文件是在你提供给连接器的目录之一。你必须提供目录的链接,因为你告诉链接器你可以看看在这些地方为我的项目需要的库。如果没有指定,它无处可看。 (

Verify the folders/paths you provide to the linker and verify that the file the linker is looking for is in one of the directories that you're providing to the linker. You have to provide directories to the linker because you're telling the linker "you can look in all of these places for the libraries my project needs". If you specify none, it's got nowhere to look. :(

例如:

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

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