or-tools: Possible link error when using or-tools on MacOS

What version of OR-Tools and what language are you using? Version: v9.5 Language: C++ - Apple clang version 14.0.0 (clang-1400.0.29.202)

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) ILP solver

What operating system (Linux, Windows, …) and version? macOS Ventura 13.2.1

What did you do? Steps to reproduce the behavior:

  1. Downloaded or-tools from https://github.com/google/or-tools/releases/download/v9.5/or-tools_x86_64_macOS-13.0.1_cpp_v9.5.2237.tar.gz
  2. Run “tar --strip 1 --dir /usr/local/opt/or-tools -xf or-tools_x86_64_macOS-13.0.1_cpp_v9.5.2237.tar.gz”
  3. Run “export CMAKE_PREFIX_PATH=$(brew --prefix or-tools)”
  4. Run cmake and make in my project, build have no errors.
  5. Execute the generated binary

What did you expect to see The binary should run with no errors.

What did you see instead? ERROR: Something is wrong with flag 'flagfile' in file 'Users/corentinl/work/or-tools/build_make/_deps/absl-src/absl/flags/parse.cc'. One possibility: file 'Users/corentinl/work/or-tools/build_make/_deps/absl-src/absl/flags/parse.cc' is being linked both statically and dynamically into this executable. e.g. some files listed as srcs to a test and also listed as srcs of some shared lib deps of the same test. Note that this error happens without executing a specific script, or even calling an or-tool functionality. The error happens when the application starts.

Make sure you include information that can help us debug (full error message, model Proto).

Anything else we should know about your project / environment The project I’m working on is The OpenROAD Project. The repository with the project code is available here: https://github.com/The-OpenROAD-Project/OpenROAD.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 25

Commits related to this issue

Most upvoted comments

OpenROAD v2.0-13237-g874ac1a7c Features included (+) or not (-): +Charts +GPU +GUI +MPL2 +PAR +Python

Using “brew install or-tools” which installs ortools 9.9 I was able to link an openroad executable without the previous or-tools related runtime error with MPL2 and PAR compiled in.

OpenRoad used to use wget to install the or-tools tar.gz.

I just noticed that I can use “brew install or-tools” and with that openroad can build an executable that works “out of the box”.

Any chance to find somebody with enough cmake knowledge on the or-tools side to put the libortools.dylib at the end of the link information that ortools cmake provides to OpenRoad via the “find_package(ortools REQUIRED)” command ?

How is this an openroad integration issue when cmake “find_package(ortools REQUIRED)” returns the libraries to be linked with in an order that allows linking to succeed, but that leads to a runtime error ?

In order to get an executable without runtime error one has to put libortools.9.6.dylib after libabsl_flags_reflection.a during linking.

@Mizux This has been on the TODO list for a while now, is there a chance that this will be addressed for the next release ? The fix is to “put the ortools.dylib at the end of the link list” that get’s used by cmake “find_package(ortools)”.

It seems that or-tools itself controls the cmake library ordering. Does this give anyone a hint on how to resolve this?

I had this problem and wanted to share my work around for it when I build or tools I now use -DBUILD_SHARED_LIBS=OFF as a cmake configure flag this causes it to build a static version of ortools lib and avoids the error

cmake -S. -Bbuild -DBUILD_SHARED_LIBS=OFF -DBUILD_DEPS:BOOL=ON -DUSE_SCIP=OFF -DUSE_GLPK=OFF -DUSE_COINOR=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build build --target install -j 8 --config Release

can you try with 9.6 ? (once the binary artefact is uploaded to github)