【问题标题】:or-tools: build examples on vs2022or-tools:在 vs2022 上构建示例
【发布时间】:2022-08-19 23:02:03
【问题描述】:

我已经下载了二进制文件:or-tools_VisualStudio2022-64bit_v9.3.10497

我在win10上使用vs2022。如果它是相关的,我的 shell 在路径中有 cygwin。

我跑了

%comspec% /k \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat\"

cl.exe 在路径中,which.exe 找到它。

我跑了make test_cc,但它抱怨

在您的 PATH 中找不到 cl 命令 127号出口 make: *** [Makefile:271: test_cc] 错误 127

即使which cl 返回了正确的路径,var CXX_BIN 也是空的。我手动将其设置为 cl。 然后,有人抱怨回声和换行符,我将其注释掉。然后,它找不到md,所以我手动创建了md objs。 构建了一些示例,但随后又因另一个错误而停止。现在,我得到了我想要的:

make run SOURCE=examples/cpp/solve.cc

但可能有更简单的方法来获得它?


我尝试使用 cmake 从源代码构建它。也不是现成的:

Build abseil-cpp: OFF
...
CMake Error at C:/prj-external-libs/vcpkg/scripts/buildsystems/vcpkg.cmake:824 (_find_package):
  By not providing \"Findabsl.cmake\" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by \"absl\", but
  CMake did not find one.

  Could not find a package configuration file provided by \"absl\" with any of
  the following names:

    abslConfig.cmake
    absl-config.cmake

  Add the installation prefix of \"absl\" to CMAKE_PREFIX_PATH or set
  \"absl_DIR\" to a directory containing one of the above files.  If \"absl\"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  cmake/deps.cmake:33 (find_package)
  CMakeLists.txt:304 (include)

如果找到gurobi95.dll,但找不到函数GRBtunemodeladv

失败时,solve.exe 在堆栈跟踪中以(未知)名称崩溃。需要添加调试符号和优雅的错误处理。


cmake 看起来更有希望,而且我缺少依赖项。应该给它一个标志-DBUILD_DEPS:BOOL=ON

    标签: or-tools


    【解决方案1】:
    1. OR-Tools 依赖于很少的外部依赖项,因此 CMake 构建将尝试使用惯用的 find_package() => 您的发行版/环境(vcpkg ?)必须提供它们,这里只是常规的 CMake 东西。
      参考:https://cmake.org/cmake/help/latest/command/find_package.html
      注意:我们在这里提供很少的findFoo.cmake https://github.com/google/or-tools/tree/main/cmake

    2. 我们还提供了一个元选项来静态构建我们所有的依赖项,只需在配置时传递-DBUILD_DEPS=ON cmake 选项。

    3. 您也可以只构建其中的一些,请看一下 https://github.com/google/or-tools/tree/main/cmake#dependencies

    4. 关于 Gurobi 和 GRBtunemodeladv 符号,这个符号已被 Gurobi 的上一版本删除,因此我们在 v9.4/main/stable 分支中修复它...
      见:https://github.com/google/or-tools/commit/d6e0feb8ae96368523deb99fe4318d32e80e8145

    【讨论】:

      猜你喜欢
      • 2021-12-25
      • 2015-07-05
      • 2020-04-21
      • 2021-12-18
      • 2014-12-22
      • 2022-06-30
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      相关资源
      最近更新 更多