skip to Main Content

I’m using ortools in c++ to model a vehicle routing problem. I was wondering whether there was a way to compile the code using my own Makefile by including the proper flags for the compiler, so that I don’t have to use

make build SOURCE=/path/to/my/program

I have compiled ortools from source on Debian 10, making sure to follow the proper instructions on the guide (make third-party then make cc then make install_cc). make test_cc runs and finished without problems, so I don’t think there is any issues with the installation.

The only clue that I found about this topic was someone writing they used

g++ -std=c++11 -o my_program my_program.cc -I/usr/local/include/or-tools -lortools

to compile their program, but upon trying that, I have a lot of undefined references. I have read somewhere that one should use -std=c++17 instead of -std=c++11 but either way it does not work.

Please let me know if you need more details.

2

Answers


  1. All binary packages comes with a supplied makefile.

    You can see the source here: https://github.com/google/or-tools/blob/stable/tools/Makefile.cc.java.dotnet

    If you run make detect_cc. It will print out all compiling and linking options for your platform.

    Login or Signup to reply.
  2. Since ortools is a shared library, you will have to specify its path using the environment variable LD_LIBRARY_PATH in addition to specifying the path using the -L flag.

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:<path-to-lib>.
    

    You can put the export command above in the .bashrc file or run it every time your run the code. Also, you will have to used C++17.

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