skip to Main Content

Windows 10 21H2 19044.1645
Microsoft Visual Studio Enterprise 2022 (64-bit) – Current Version 17.7.6
or-tools_x64_VisualStudio2022_cpp_v9.7.2996

I have been using the python version of or-tools before, and now I want to try the c++ version. But I tried for two days and search a lot of information on the Internet, but I still couldn’t get the program to run. I don’t know which one I did wrong or what steps I missed. I hope you can help me figure it out.

Details are as follows:

I download the binary distribution: or-tools_x64_VisualStudio2022_cpp_v9.7.2996.zip and extracted it to the directory: "E:Microsoft Visual StudioLibsor-tools_x64_VisualStudio2022_cpp_v9.7.2996".

I create a new Empty Project (C++) and name it "TestProject" in Visual Studio, and the project will be created in "E:Microsoft Visual StudioProjectTestProject".

I Add > New Item and name it "program.cc" as file name in the project, and I copy and paste the code which is in Get Started with OR-Tools for C++ into the "program.cc" file.

I right-clicked the project to open Properties and modified the following settings for both Configuration: Release and Configuration: Debug:
Set Configuration Properties > General > C++ Language Standard to ISO C++17 Standard (/std:c++17).
Set Configuration Properties > C/C++ > Code Generation > Runtime Library to Multi-threaded DLL (/MD).
Add E:Microsoft Visual StudioLibsor-tools_x64_VisualStudio2022_cpp_v9.7.2996include into Configuration Properties > C/C++ > General > Additional Include Directories.
Add E:Microsoft Visual StudioLibsor-tools_x64_VisualStudio2022_cpp_v9.7.2996lib into Configuration Properties > Linker > General > Additional Library Directories.
Add ortools_full.lib into Configuration Properties > Linker > Input > Additional Dependencies.

I select Solution Configurations as Release, and I select Solution Platforms as x64, and I press ▶ Local Windows Debugger so the program starts running.

And I get 7 Errors, 200 Warnings, 0Messages.

Error List:
enter image description here

Output:
enter image description here

Please help me, thank you.

Crossposted at https://github.com/google/or-tools/discussions/3963

2

Answers


  1. On Windows, or-tools is built against /std:c++20 since code use some aggregate initialization…

    ref: https://en.cppreference.com/w/cpp/language/aggregate_initialization

    note: This has been silently enabled in gcc/clang in -std=c++17 so unix like OS (linux, macOS) are compiled against C++17…

    note2: "designator expression" is supported since C99.

    Login or Signup to reply.
  2. I had the same issue when using or-tools in Visual Studio.

    I found this thread: https://github.com/google/or-tools/issues/3888

    It looks like utf8_validity.cc is missing from the build. A quick fix described in the above link is to add https://github.com/protocolbuffers/utf8_range/blob/main/utf8_validity.cc to your project. This fixes the linking error in my project, and the code is running now. Perhaps worth a try 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search