【问题标题】:Linker Error while building application using Boost Asio in Visual Studio C++ 2008 Express在 Visual Studio C++ 2008 Express 中使用 Boost Asio 构建应用程序时出现链接器错误
【发布时间】:2009-04-01 06:23:43
【问题描述】:

我刚开始使用 Visual Studio C++ 2008 Express 用 C++ 编写一个小型应用程序。我使用 Windows 安装程序安装了 Boost Library。编译程序时出现以下错误:

正在编译...
stdafx.cpp
正在编译...
websave.cpp
GoogleAuthenticate.cpp
生成代码...
将清单编译为资源...
Microsoft (R) Windows (R) 资源编译器版本 6.1.6723.1
版权所有 (C) 微软公司。保留所有权利。
正在链接...
链接:致命错误 LNK1104:无法打开文件“libboost_system-vc90-mt-gd-1_38.lib”

// GoogleAuthenticate.h

#pragma once
#include <boost/asio.hpp>

class GoogleAuthenticate
{
  public:
        GoogleAuthenticate(void);
        virtual ~GoogleAuthenticate(void);
};

// GoogleAuthenticate.cpp

#include "StdAfx.h"
#include "GoogleAuthenticate.h"


GoogleAuthenticate::GoogleAuthenticate(void)
{
}

GoogleAuthenticate::~GoogleAuthenticate(void)
{
}

// websave.cpp

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{ 
    cout << "hello" << endl; 
return 0;
}

我检查了 boost/boost-1.38/lib 文件夹,并且 libboost_system-vc90-mt-gd-1_38.lib 在那里。还在项目的配置属性中的“其他包含目录”中添加了路径。

这里有什么遗漏的吗?

【问题讨论】:

    标签: c++ visual-studio boost linker


    【解决方案1】:

    您还可以将它添加到该特定项目的库目录中。右键单击项目,属性 -> 链接器 -> 常规 -> 附加库目录。

    我们这样做是因为我们可以在我们的配置管理结构中为不同的项目提供不同版本的 boost。如果您只想使用 PC 上安装的任何版本,请使用工具菜单中的设置:工具 -> 选项 -> 项目和解决方案 -> VC++ 目录 -> 库文件。

    【讨论】:

      【解决方案2】:

      您还需要将该目录添加到库目录列表中。

      Tools | Options | Projects | VC++ Directories
      

      【讨论】:

        【解决方案3】:

        忘记添加了: 在 Configuration Properties > Linker > Additional Library Directories 中,输入 Boost 二进制文件的路径,例如C:\Program Files\boost\boost_1_38_0\lib.

        应该有 RTFM。 http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html#link-from-within-the-visual-studio-ide

        已修复。

        【讨论】:

          猜你喜欢
          • 2018-12-14
          • 2013-01-17
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多