You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS2015使用vc14工具集安装Boost 1.63/1.64执行bootstrap.bat报错

VS2015 编译Boost 1.63/1.64 执行bootstrap.bat报错修复

问题描述

Visual Studio 2015环境下使用C++ Boost库1.63.0或1.64.0版本时,使用vc14工具集安装Boost.Build,执行bootstrap.bat触发运行异常。
Bootstrap.log记录的报错片段如下:

正在使用'vc14'工具集。

F:\SunGard_04022016\code\boost\boost_1_63_0\tools\build\src\engine>if exist bootstrap rd /S /Q bootstrap 
F:\SunGard_04022016\code\boost\boost_1_63_0\tools\build\src\engine>md bootstrap 
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\malloc.h(104): error C2054: expected '(' to follow '_CRTNOALIAS'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\malloc.h(104): error C2085: 'calloc': not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\malloc.h(105): error C2061: syntax error: identifier '_CRTNOALIAS'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\malloc.h(106): error C2054: expected '(' to follow '_CRTNOALIAS'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\malloc.h(106): error C2085: 'malloc': not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\malloc.h(110): error C2054: expected '(' to follow '_CRTNOALIAS'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\stdio.h(309): error C2085: 'scanf_s': not in formal parameter list
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\stdio.h(311): error C2061: syntax error: identifier '_CRTIMP_ALTERNATIVE'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\stdio.h(362): warning C4081: expected ')'; found 'string'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\stdio.h(363): warning C4003: not enough actual parameters for macro '__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX'
......

故障原因

VS2015安装KB3165756等后续更新补丁后,VC运行时头文件新增_CRTNOALIAS、_CRTIMP_ALTERNATIVE等修饰宏,Boost 1.63、1.64版本自带的Boost.Build编译配置未适配该变更。bootstrap阶段编译b2引擎时,未加载完整的VC编译环境变量,编译器无法识别上述新增宏,将宏名当作普通代码解析,触发语法错误。

修复方案

任选以下一种方法即可解决:

  • 方法一:使用VS原生命令行执行(无需改文件)
    从开始菜单打开对应目标平台的VS2015 本机工具命令提示符,切换到Boost根目录后执行bootstrap.bat vc14。该命令行环境会自动加载完整的VC编译环境变量和宏定义,不会出现识别失败问题。
  • 方法二:修改bootstrap脚本适配补丁
    打开Boost根目录下的bootstrap.bat,找到编译参数配置行(类似set "B2_CCFLAGS=%B2_CCFLAGS% -D_CRT_SECURE_NO_WARNINGS"),在该行后追加以下参数定义:
    set "B2_CCFLAGS=%B2_CCFLAGS% -D_CRTNOALIAS= -D_CRTIMP_ALTERNATIVE=__declspec(dllimport)"
    
    保存后重新执行bootstrap.bat即可正常完成编译。
  • 方法三:升级Boost版本
    更换为Boost 1.65.0及以上版本,官方已在新版本中修复该兼容性问题,无需额外修改配置即可直接在更新后的VS2015环境下编译通过。

内容的提问来源于stack exchange,提问作者Sunil chouksey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 19:12:44