如何解决LNK1104错误与提高文件系统库中MSCV? [英] How do I resolve LNK1104 error with Boost Filesystem Library in MSCV?

查看:148
本文介绍了如何解决LNK1104错误与提高文件系统库中MSCV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦我的项目链接到升压(1.37.0版本)在Microsoft Visual C ++ 2008例preSS版文件系统库文件。 Filesystem库为不是仅头库。我一直在关注的 入门在Windows 引导张贴的官方提振网页上。下面是我所采取的步骤:


  1. 我用的bjam构建使用LIB文件的完整集合:

     的bjam --build-DIR =C:\\ Program Files文件\\提升\\集结助推--toolset = MSVC --build型=完整


  2. 我复制的 /库的目录(位于 C:\\ Program Files文件\\提升\\ build中 - 升压\\提升\\ bin.v2 ),以<我> C:\\ Program Files文件\\提升\\ boost_1_37_0 \\库


  3. 在Visual C ++,在项目>属性>附加库目录我添加这些路径:


    • C:\\ Program Files文件\\提升\\ boost_1_37_0 \\库

    • C:\\ PROGRAM Files\\boost\\boost_1_37_0\\libs\\filesystem\\build\\msvc-9.0ex$p$pss\\debug\\link-static\\threading-multi

    我添加了第二个绝望的。这是确切的目录,其中 libboost_system-vc90-MT-GD-1_37.lib 所在。


  4. 配置属性> C / C ++>常规>附加包含目录添加以下路径:


    • C:\\ Program Files文件\\提升\\ boost_1_37_0


  5. 然后,把锦上添花,在工具>选项VC ++目录>库文件的,我加在第3步中提到的相同的目录。


尽管如此,当我建立我的项目,我收到以下错误:

 致命错误LNK1104:无法打开文件'libboost_system-vc90-MT-GD-1_37.lib

此外,这里是code,我试图编译以及前述方式目录的屏幕截图,其中(assumedly正确)的lib文件所在:

 的#include助推/ filesystem.hpp//包括所有需要的Boost.Filesystem的声明
#包括LT&;&iostream的GT; //性病::法院
使用boost ::文件系统; //为便于教程presentation的;
                                  //命名空间别名是在现实code preferred实践使用命名空间std;诠释的main()
{
    COUT&LT;&LT; 你好,世界! &LT;&LT; ENDL;    返回0;
}


解决方案

费鲁乔的回答包含了大部分的洞察力。然而,Pukku使我认识到我的错误。我张贴我自己的答案给出全面的解释。由于费鲁乔解释说,文件系统依赖于两个库。对我来说,它们是:


  • libboost_system-vc90-MT-GD-1_37.lib

  • libboost_filesystem-vc90-MT-GD-1_37.lib

我一定没有注意到,当我为提供目录 libboost_filesystem-vc90-MT-GD-1_37.lib ,错误输出

改变

 致命错误LNK1104:无法打开文件'libboost_filesystem-vc90-MT-GD-1_37.lib

 致命错误LNK1104:无法打开文件'libboost_system-vc90-MT-GD-1_37.lib

害我认为错误是坚持。这导致我张贴一些相当不准确的信息。此外,读取文件系统需要两个库后,我现在看到的关键字舞台的bjam的命令的意义。直供

 的bjam --build-DIR =C:\\ Program Files文件\\提升\\集结助推--toolset = MSVC --build型=完整的舞台

原因的bjam放置一个额外的目录,取名为 boost_1_37_0 目录。此文件夹包含一个名为 / lib目录的文件夹,里面有所有的lib文件的副本在一个地方。这是方便的Visual C ++,因为你可以用这个单一的目录提供它,它会采取所有的依赖护理。

I am having trouble getting my project to link to the Boost (version 1.37.0) Filesystem lib file in Microsoft Visual C++ 2008 Express Edition. The Filesystem library is not a header-only library. I have been following the Getting Started on Windows guide posted on the official boost web page. Here are the steps I have taken:

  1. I used bjam to build the complete set of lib files using:

    bjam --build-dir="C:\Program Files\boost\build-boost" --toolset=msvc --build-type=complete
    

  2. I copied the /libs directory (located in C:\Program Files\boost\build-boost\boost\bin.v2) to C:\Program Files\boost\boost_1_37_0\libs.

  3. In Visual C++, under Project > Properties > Additional Library Directories I added these paths:

    • C:\Program Files\boost\boost_1_37_0\libs
    • C:\Program Files\boost\boost_1_37_0\libs\filesystem\build\msvc-9.0express\debug\link-static\threading-multi

    I added the second one out of desperation. It is the exact directory where libboost_system-vc90-mt-gd-1_37.lib resides.

  4. In Configuration Properties > C/C++ > General > Additional Include Directories I added the following path:

    • C:\Program Files\boost\boost_1_37_0
  5. Then, to put the icing on the cake, under Tools > Options VC++ Directories > Library files, I added the same directories mentioned in step 3.

Despite all this, when I build my project I get the following error:

fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_37.lib'

Additionally, here is the code that I am attempting to compile as well as a screen shot of the aformentioned directory where the (assumedly correct) lib file resides:

#include "boost/filesystem.hpp"   // includes all needed Boost.Filesystem declarations
#include <iostream>               // for std::cout
using boost::filesystem;          // for ease of tutorial presentation;
                                  //  a namespace alias is preferred practice in real code

using namespace std;

int main()
{
    cout << "Hello, world!" << endl;

    return 0;
}

解决方案

Ferruccio's answer contains most of the insight. However, Pukku made me realize my mistake. I am posting my own answer to give a full explanation. As Ferruccio explained, Filesystem relies on two libraries. For me, these are:

  • libboost_system-vc90-mt-gd-1_37.lib
  • libboost_filesystem-vc90-mt-gd-1_37.lib

I must not have noticed that when I supplied the directory for libboost_filesystem-vc90-mt-gd-1_37.lib, the error output changed from

fatal error LNK1104: cannot open file 'libboost_filesystem-vc90-mt-gd-1_37.lib'

to

fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-gd-1_37.lib'

Causing me to think that the error was persisting. This lead me to post some rather inaccurate information. Also, after reading that Filesystem requires two libraries, I now see the significance of the keyword stage for the bjam command. Supplying

bjam --build-dir="C:\Program Files\boost\build-boost" --toolset=msvc --build-type=complete stage

Causes bjam to place an additional directory, aptly named stage, in the boost_1_37_0 directory. This folder contains a folder named /lib, which has copies of all of the lib files in one place. This is convenient for Visual C++ because you can supply it with this single directory and it will take care of all of the dependencies.

这篇关于如何解决LNK1104错误与提高文件系统库中MSCV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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