【问题标题】:How do I compile boost using a specific VC++ Runtime?如何使用特定的 VC++ 运行时编译 boost?
【发布时间】:2013-02-27 03:13:46
【问题描述】:

我正在尝试获得一致的 VC++ 运行时进行分发,但我找不到任何迫使 boost/bjam 合作的东西。

我已经用这个链接中的方法成功编译了libcurl和UnitTest++。

Avoiding problems with VC2005 SP1 Security update KB971090

一般的策略是在所有 cpp 文件中包含这个头文件。

#ifndef __midl
#define _SXS_ASSEMBLY_VERSION "8.0.50727.762"
#define _CRT_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION
#define _MFC_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION
#define _ATL_ASSEMBLY_VERSION _SXS_ASSEMBLY_VERSION
#ifdef __cplusplus
extern "C" {
#endif
__declspec(selectany) int _forceCRTManifest;
__declspec(selectany) int _forceMFCManifest;
__declspec(selectany) int _forceAtlDllManifest;
__declspec(selectany) int _forceCRTManifestRTM;
__declspec(selectany) int _forceMFCManifestRTM;
__declspec(selectany) int _forceAtlDllManifestRTM;
#ifdef __cplusplus
}
#endif
#endi

b2 具有设置 cxxflags 的选项,尽管它们似乎不尊重我的 /FI 编译选项来使用标头并强制执行正确的运行时。我假设他们正在使用其他东西。我想 boost 不使用 msvc 标志?

我想专门用8.0.50727.762 编译 boost。

【问题讨论】:

    标签: c++ boost boost-build


    【解决方案1】:

    显然 bjam 对哪些标志有前导 -- 破折号很挑剔。

    bjam ^
        toolset=msvc-8.0 ^
        link=static ^
        cxxflags=/FI"C:/boost_1_44_0/sxs_header.h" ^
        --with-thread ^
        --with-date_time ^
        --with-system ^
        -d2
    

    将产生正确的编译器标志:

    file bin.v2\libs\thread\build\msvc-8.0\release\link-static\threading-multi\win32\thread.obj.rsp
    "libs\thread\src\win32\thread.cpp"
     -Fo"bin.v2\libs\thread\build\msvc-8.0\release\link-static\threading-multi\win32\thread.obj"
        -TP
     /O2
     /Ob2
     /W3
     /GR
     /MD
     /Zc:forScope
     /Zc:wchar_t
     /wd4675
     /EHs
     /FIC:/boost_1_44_0/sxs_header.h
     -c
    
    -DBOOST_ALL_NO_LIB=1
    
    -DBOOST_THREAD_BUILD_LIB=1
    
    -DNDEBUG
    
    "-I."
    
    compile-c-c++ bin.v2\libs\thread\build\msvc-8.0\release\link-static\threading-multi\win32\thread.obj
    
        call "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86 >nul
    cl /Zm800 -nologo @"bin.v2\libs\thread\build\msvc-8.0\release\link-static\threading-multi\win32\thread.objp"
    
    thread.cpp
    

    您可以通过创建一个测试应用程序来验证这一点,该应用程序使用需要 boost 来链接的东西,然后在中间目录中检查其清单文件。

    <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
    <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
        </dependentAssembly>
      </dependency>
    </assembly>
    

    您应该只看到具有正确版本的assemblyIdentity,否则您通常会看到数字更高的一对。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-09
      • 2016-12-23
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-25
      • 2011-01-16
      相关资源
      最近更新 更多