3

我在尝试使用 Visual Studio 2012 Pro 编译带有 boost 的简单示例时遇到了问题。我已经成功下载并编译了 boost (ver 1.54.0)。我在发布版和调试版中都编译了示例的 32 位版本(Win32 配置)。然后我尝试构建 64 位(因为我有 64 位 Windows 7)。我按照此处的说明进行操作:如何:将 Visual C++ 项目配置为以 64 位平台为目标。唉,编译尝试失败并出现错误:

1>server.cpp(38): fatal error C1083: Cannot open include file: 'boost/aligned_storage.hpp': No such file or directory

我检查了以下几点,现在我不知道可能出了什么问题:

  1. 该文件位于正确的位置(确切位置:C:\dev\include\boost\boost\aligned_storage.hpp)。如果没有它,那么 Win32 版本就不会编译。
  2. 我已将环境变量 INCLUDE 设置为 "C:\dev/include;C:\dev/include/boost" 。
  3. “VC++ 目录->包含目录”如下所示:

$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);$(INCLUDE);

  1. “C/C++ -> General -> Additional Include Directories” 像这样:

C:\dev\include\boost;%(AdditionalIncludeDirectories)

我要编译的代码是(这当然只是其中的一部分):

//
// server.cpp
// ~~~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//


#ifndef WINVER                  // Minimum platform is Windows 7
#define WINVER 0x0601
#endif

#ifndef _WIN32_WINNT            // Minimum platform is Windows 7
#define _WIN32_WINNT 0x0601
#endif

#ifndef _WIN32_WINDOWS          // Minimum platform is Windows 7
#define _WIN32_WINDOWS 0x0601
#endif

#include <cstdlib>
#include <iostream>
#include <boost/aligned_storage.hpp>
#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>

using boost::asio::ip::tcp;

我的 x64\Debug\BoostExample.log 的内容:

Build started 2013-07-15 19:45:53.
 1>Project "C:\Users\LF\Develop\BoostExample\BoostExample\BoostExample.vcxproj" on node 2 (Build target(s)).
 1>ClCompile:
     C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\CL.exe /c /Zi /nologo /W3 /WX- /Od /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"x64\Debug\\" /Fd"x64\Debug\vc110.pdb" /Gd /TP /errorReport:prompt server.cpp
     server.cpp
 1>server.cpp(38): fatal error C1083: Cannot open include file: 'boost/aligned_storage.hpp': No such file or directory
 1>Done Building Project "C:\Users\LF\Develop\BoostExample\BoostExample\BoostExample.vcxproj" (Build target(s)) -- FAILED.

Build FAILED.

Time Elapsed 00:00:00.28

为了比较这里是 Release\BoostExample.log (成功的 32 位编译):

Build started 2013-07-15 20:06:17.
 1>Project "C:\Users\LF\Develop\BoostExample\BoostExample\BoostExample.vcxproj" on node 2 (Build target(s)).
 1>ClCompile:
     C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D _MBCS /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt server.cpp
     server.cpp
   Link:
     C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\LF\Develop\BoostExample\Release\BoostExample.exe" /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\LF\Develop\BoostExample\Release\BoostExample.pdb" /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\LF\Develop\BoostExample\Release\BoostExample.lib" /MACHINE:X86 /SAFESEH Release\server.obj
     Generating code
     Finished generating code
     BoostExample.vcxproj -> C:\Users\LF\Develop\BoostExample\Release\BoostExample.exe
 1>Done Building Project "C:\Users\LF\Develop\BoostExample\BoostExample\BoostExample.vcxproj" (Build target(s)).

Build succeeded.

Time Elapsed 00:00:02.50

任何帮助将不胜感激:D。

在此先感
谢乐虎

4

0 回答 0