or-tools: build examples on vs2022

Viewed 49

I've downloaded the binaries: or-tools_VisualStudio2022-64bit_v9.3.10497

I'm using vs2022 on win10. My shell has cygwin in the path if it's related.

I ran

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

cl.exe is in the path, and which.exe finds it.

I ran make test_cc, but it complained

the cl command was not found in your PATH exit 127 make: *** [Makefile:271: test_cc] Error 127

The var CXX_BIN was empty even though which cl returned the correct path. I set it manually to cl. Then, there was a complaint about echo and a newline, which I commented out. Then, it couldn't find md, so I created manually md objs. A few of the examples were built, but then it stopped with another error. For now, I just got what I want:

make run SOURCE=examples/cpp/solve.cc

but probably there was an easier way to get it?


I tried to build it from the source using cmake. Doesn't work off-the-shelf as well:

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)

If finds gurobi95.dll, but it can't find the function GRBtunemodeladv.

On failure, solve.exe crashes with (unknown) names in the stack trace. Need to add debug symbols and graceful error handling.


cmake looks more promising, and I was missing dependencies. Should give it a flag -DBUILD_DEPS:BOOL=ON.

1 Answers
  1. OR-Tools depends on few external dependencies so CMake build will try to find them using the idiomatic find_package() => your distro/env(vcpkg ?) must provide them, just regular CMake stuff here.
    ref: https://cmake.org/cmake/help/latest/command/find_package.html
    note: we provide few findFoo.cmake here https://github.com/google/or-tools/tree/main/cmake

  2. We also provide a meta option to build statically all our dependencies, simply pass -DBUILD_DEPS=ON cmake option at configure time.

  3. You can also build only some of them, please take a look at https://github.com/google/or-tools/tree/main/cmake#dependencies

  4. Concerning Gurobi and GRBtunemodeladv symbol, this one has been removed by last version of Gurobi so we fix it in v9.4/main/stable branch...
    see: https://github.com/google/or-tools/commit/d6e0feb8ae96368523deb99fe4318d32e80e8145

Related