Or-tools: Build error in CHECK macro with params.MergeFromString

Created on 15 Jul 2020  Â·  6Comments  Â·  Source: google/or-tools

What version of OR-tools and what language are you using?
Version: 45770b833997f827d322e929b1ed4781c4e60d44
Language: C++

What operating system (Linux, Windows, ...) and version?
Ubuntu Focal

What did you do?
Compile using CMake

What did you expect to see
Code compiling.

What did you see instead?

[ 54%] Building CXX object ortools/linear_solver/CMakeFiles/ortools_linear_solver.dir/sat_proto_solver.cc.o
In file included from /home/administrator/ortools_ws/src/or-tools/ortools/base/logging.h:23,
                 from /home/administrator/ortools_ws/src/or-tools/ortools/base/statusor.h:18,
                 from /home/administrator/ortools_ws/src/or-tools/ortools/linear_solver/sat_proto_solver.h:17,
                 from /home/administrator/ortools_ws/src/or-tools/ortools/linear_solver/sat_proto_solver.cc:14:
/home/administrator/ortools_ws/src/or-tools/ortools/linear_solver/sat_proto_solver.cc: In function ‘absl::StatusOr<operations_research::MPSolutionResponse> operations_research::SatSolveProto(operations_research::MPModelRequest, std::atomic<bool>*)’:
/home/administrator/ortools_ws/src/or-tools/ortools/linear_solver/sat_proto_solver.cc:69:20: error: ‘class operations_research::sat::SatParameters’ has no member named ‘MergeFromString’; did you mean ‘ParseFromString’?
   69 |       CHECK(params.MergeFromString(request.solver_specific_parameters()));
      |                    ^~~~~~~~~~~~~~~
make[2]: *** [ortools/linear_solver/CMakeFiles/ortools_linear_solver.dir/build.make:271: ortools/linear_solver/CMakeFiles/ortools_linear_solver.dir/sat_proto_solver.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1575: ortools/linear_solver/CMakeFiles/ortools_linear_solver.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

I made the proposed change to ParseFromString and this allowed it to compile, or I could disable asserts, but there appear to be lots of other instances of this in the code.

Bug CMake Feature Request C++ Linux

All 6 comments

which CMake command did you use ?

Pretty vanilla. I'm actually building in a ROS workspace with catkin_tools, so I need to patch in a handful of other changes to make that work, but it basically boils down to:

mkdir build; cd build
cmake .. -DBUILD_PYTHON=ON -DBUILD_EXAMPLES=OFF -DBUILD_DEPS=OFF -DBUILD_CoinUtils=ON -DBUILD_Osi=ON -DBUILD_Clp=ON -DBUILD_Cgl=ON -DBUILD_Cbc=ON
make

Against https://github.com/abseil/abseil-cpp/commit/55c04eb9203a93db1c0816adddf3182b45da5384, which upon reflection may be the issue here, given that it appears to be tripping up on an Abseil API.

On master I saw:

ortools/linear_solver/bop_interface.cc:381:      google::protobuf::TextFormat::MergeFromString(parameters, &parameters_);

-> which version of Protobuf did you used ? (ed usually we try to target the last available version so code outside is close to what we have inside reducing the maintenance cost)

This is with protobuf 3.6.1.3 as packaged in Ubuntu Focal:

$ dpkg -l libprotobuf-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version          Architecture Description
+++-=====================-================-============-================================================================
ii  libprotobuf-dev:amd64 3.6.1.3-2ubuntu5 amd64        protocol buffers C++ library (development files) and proto files

Admittedly, that's from Dec 2018, but if the intent is to support building against system versions of your deps (to enable a sane story for maintainers doing downstream packaging), supporting the latest Ubuntu LTS versions of them is probably about the minimum.

This is what's available in protobuf v3.6.1.3: https://github.com/protocolbuffers/protobuf/blob/v3.6.1.3/src/google/protobuf/message_lite.cc

MergeFromCodedStream might be the thing? Or just a straight Merge after ParseFromString?

Due to lack of human ressource to support multiple version of Protobuf (I.e. lag behind the google internal source code state) as well as the Google abseil support policy to "force" OSS projects to "live at head".

We won't support older version of Protobuf, so I hope OSS Ubuntu community will catch up with a recent version of Protobuf (like Homebrew-core, FreeBSD, Alpine, Archlinux etc... did).
note: Since we also provide Python (pip), Java (maven) and .Net (nuget) package, we try to keep in sync with the last available version of our dependencies (I.e. Protobuf release).

Was this page helpful?
0 / 5 - 0 ratings