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

Windows11下启用XPRESS编译OR-Tools(Java稳定版)失败求助

OR-Tools 构建时 scip_update_githash 自定义构建错误解决方法

环境信息

  • OR-Tools版本:稳定版
  • 开发语言:Java
  • 操作系统:Windows 11 64位
  • 已安装依赖:Java、Maven、Visual Studio Enterprise 2022、Swig、ProtoBuf、带许可的XPRESS
  • 成功执行的配置命令:
    cmake -S . -B build -DBUILD_DEPS=ON -DBUILD_JAVA=ON -DUSE_XPRESS=ON -DXPRESS_ROOT=C:\xpressmp -DXPRESS_LIBRARIES=C:\xpressmp\lib -DXPRESS_INCLUDE_DIRS=C:\xpressmp\include -A x64
    
  • 执行失败的构建命令:
    cmake --build build --config Release --target ALL_BUILD -j4 -v --clean-first
    
  • 错误信息:

    "C:\Users**\Documents**\Projects\or-tools\build\ALL_BUILD.vcxproj" (default target) (1)
    ->
    "C:\Users**\Documents**\Projects\or-tools\build\ortools\graph\samples\assignment_linear_sum_assignment.vcxproj" (default target) (14)
    ->
    "C:\Users**\Documents**\Projects\or-tools\build_deps\scip-build\src\libscip.vcxproj" (default target) (86)
    ->
    "C:\Users**\Documents**\Projects\or-tools\build_deps\scip-build\scip_update_githash.vcxproj" (default target) (88)
    ->
    (CustomBuild target) ->
    C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'C:\Users**\Documents**\Projects\or-tools\build\CMakeFiles\7e2c4873001c5a9dbebf1c1a1b7cc43f\scip_update_githash.rule' exited with code 1. [C:\Users\SnehasishChar\Documents**\Projects\or-tools\build_deps\scip-build\scip_update_githash.vcxproj]

解决方法

1. 检查Git安装与PATH配置

scip_update_githash目标依赖Git获取哈希值,需确保:

  • 已安装Git for Windows(建议版本2.20+)
  • Git已添加到系统环境变量PATH中
  • 打开新终端执行git --version,确认能正常输出版本信息

2. 禁用SCIP的Git哈希更新

若不需要SCIP的Git哈希信息,修改cmake配置命令添加跳过参数:

cmake -S . -B build -DBUILD_DEPS=ON -DBUILD_JAVA=ON -DUSE_XPRESS=ON -DXPRESS_ROOT=C:\xpressmp -DXPRESS_LIBRARIES=C:\xpressmp\lib -DXPRESS_INCLUDE_DIRS=C:\xpressmp\include -A x64 -DSCIP_DEVELOPMENT=OFF

之后重新执行原构建命令。

3. 手动创建Git哈希文件

进入build_deps/scip-build目录,创建git_hash.h文件,内容填入:

#define GITHASH "dummy-hash"

保存后重新执行构建命令。

4. 以管理员权限运行终端

右键命令提示符/终端,选择「以管理员身份运行」,再重新执行构建命令,避免权限不足导致的文件写入失败。

5. 清理SCIP构建目录后重试

删除SCIP的构建目录,重新执行配置与构建:

rmdir /s /q build_deps/scip-build
cmake -S . -B build -DBUILD_DEPS=ON -DBUILD_JAVA=ON -DUSE_XPRESS=ON -DXPRESS_ROOT=C:\xpressmp -DXPRESS_LIBRARIES=C:\xpressmp\lib -DXPRESS_INCLUDE_DIRS=C:\xpressmp\include -A x64
cmake --build build --config Release --target ALL_BUILD -j4 -v --clean-first

内容的提问来源于stack exchange,提问作者Snehasish Char

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 01:05:04