ankane / or-tools-ruby

Operations research tools for Ruby
Apache License 2.0
179 stars 25 forks source link

Issue building or-tools 0.10.1 with native extensions #49

Closed ollym closed 1 year ago

ollym commented 1 year ago

This is on M1 Pro mac with latest brew update or-tools (which is 9.6)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/or-tools-0.10.1/ext/or-tools
/Users/ollym/.rbenv/versions/3.2.1/bin/ruby -I /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0 extconf.rb --with-or-tools-dir\=/opt/homebrew
checking for rice/rice.hpp in /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rice-4.1.0/include... yes
checking for -lc++... yes
checking for -lortools... yes
creating Makefile

current directory: /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/or-tools-0.10.1/ext/or-tools
make DESTDIR\= sitearchdir\=./.gem.20230628-98570-n9sw9s sitelibdir\=./.gem.20230628-98570-n9sw9s clean

current directory: /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/or-tools-0.10.1/ext/or-tools
make DESTDIR\= sitearchdir\=./.gem.20230628-98570-n9sw9s sitelibdir\=./.gem.20230628-98570-n9sw9s
compiling assignment.cpp
compiling bin_packing.cpp
compiling constraint.cpp
compiling ext.cpp
compiling linear.cpp
compiling network_flows.cpp
compiling routing.cpp
linking shared-object or_tools/ext.bundle
Undefined symbols for architecture arm64:
  "_FLAGS_stderrthreshold", referenced from:
      operations_research::CppBridge::SetFlags(operations_research::CppFlags const&) in ext.o
  "absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::__1::basic_string_view<char, std::__1::char_traits<char>>)", referenced from:
      Rice::detail::NativeFunction<operations_research::sat::CpSolverResponse, init_constraint(Rice::Module&)::$_44, true>::call(int, unsigned long*, unsigned long) in constraint.o
      google::protobuf::RepeatedField<int>::GrowNoAnnotate(int, int) in constraint.o
      google::protobuf::RepeatedField<int>::~RepeatedField() in constraint.o
      void google::protobuf::RepeatedField<int>::InternalDeallocate<false>() (.cold.1) in constraint.o
      Rice::detail::NativeFunction<operations_research::MPSolver, init_linear(Rice::Module&)::$_1, true>::call(int, unsigned long*, unsigned long) in linear.o
      operations_research::RoutingIndexManager::IndexToNode(long long) const (.cold.1) in routing.o
      operations_research::RoutingIndexManager::IndexToNode(long long) const (.cold.2) in routing.o
      ...
  "absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()", referenced from:
      Rice::detail::NativeFunction<operations_research::sat::CpSolverResponse, init_constraint(Rice::Module&)::$_44, true>::call(int, unsigned long*, unsigned long) in constraint.o
      google::protobuf::RepeatedField<int>::GrowNoAnnotate(int, int) in constraint.o
      google::protobuf::RepeatedField<int>::~RepeatedField() in constraint.o
      void google::protobuf::RepeatedField<int>::InternalDeallocate<false>() (.cold.1) in constraint.o
      Rice::detail::NativeFunction<operations_research::MPSolver, init_linear(Rice::Module&)::$_1, true>::call(int, unsigned long*, unsigned long) in linear.o
      operations_research::RoutingIndexManager::IndexToNode(long long) const (.cold.1) in routing.o
      operations_research::RoutingIndexManager::IndexToNode(long long) const (.cold.2) in routing.o
      ...
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<long long, long long>(long long, long long, char const*)", referenced from:
      Rice::detail::NativeFunction<operations_research::sat::CpSolverResponse, init_constraint(Rice::Module&)::$_44, true>::call(int, unsigned long*, unsigned long) in constraint.o
      google::protobuf::RepeatedField<int>::GrowNoAnnotate(int, int) in constraint.o
      google::protobuf::RepeatedField<int>::~RepeatedField() in constraint.o
      void google::protobuf::RepeatedField<int>::InternalDeallocate<false>() (.cold.1) in constraint.o
      operations_research::RoutingIndexManager::IndexToNode(long long) const (.cold.1) in routing.o
      operations_research::RoutingIndexManager::NodeToIndex(gtl::IntType<operations_research::RoutingNodeIndex_tag_, int>) const (.cold.2) in routing.o
      operations_research::RoutingModel::SetVehicleUsedWhenEmpty(bool, int) (.cold.1) in routing.o
      ...
  "absl::lts_20230125::log_internal::CheckOpMessageBuilder::ForVar2()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<absl::lts_20230125::Duration const&, absl::lts_20230125::Duration
const&>(absl::lts_20230125::Duration const&, absl::lts_20230125::Duration const&, char const*) in linear.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<long long, unsigned long long>(long long, unsigned long long, char const*) in routing.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const*) in routing.o
  "absl::lts_20230125::log_internal::CheckOpMessageBuilder::NewString()", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<absl::lts_20230125::Duration const&, absl::lts_20230125::Duration
const&>(absl::lts_20230125::Duration const&, absl::lts_20230125::Duration const&, char const*) in linear.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<long long, unsigned long long>(long long, unsigned long long, char const*) in routing.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const*) in routing.o
  "absl::lts_20230125::log_internal::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<absl::lts_20230125::Duration const&, absl::lts_20230125::Duration
const&>(absl::lts_20230125::Duration const&, absl::lts_20230125::Duration const&, char const*) in linear.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<long long, unsigned long long>(long long, unsigned long long, char const*) in routing.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<unsigned long long, long long>(unsigned long long, long long, char const*) in routing.o
  "absl::lts_20230125::InitializeLog()", referenced from:
      _Init_ext in ext.o
  "absl::lts_20230125::hash_internal::MixingHashState::kSeed", referenced from:
      operations_research::RoutingModel::IsVehicleAllowedForIndex(int, long long) in routing.o
  "absl::lts_20230125::FormatDuration(absl::lts_20230125::Duration)", referenced from:
std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>* absl::lts_20230125::log_internal::MakeCheckOpString<absl::lts_20230125::Duration const&, absl::lts_20230125::Duration
const&>(absl::lts_20230125::Duration const&, absl::lts_20230125::Duration const&, char const*) in linear.o
  "absl::lts_20230125::flags_internal::FlagImpl::Write(void const*)", referenced from:
      operations_research::CppBridge::SetFlags(operations_research::CppFlags const&) in ext.o
  "absl::lts_20230125::EnableLogPrefix(bool)", referenced from:
      operations_research::CppBridge::SetFlags(operations_research::CppFlags const&) in ext.o
  "absl::lts_20230125::container_internal::kEmptyGroup", referenced from:
      Rice::detail::NativeFunction<unsigned long, init_constraint(Rice::Module&)::$_45, true>::call(int, unsigned long*, unsigned long) in constraint.o
      Rice::Constructor<operations_research::sat::CpModelBuilder>::construct(unsigned long) in constraint.o
  "absl::lts_20230125::ToInt64Milliseconds(absl::lts_20230125::Duration)", referenced from:
      operations_research::MPSolver::wall_time() const in linear.o
  "absl::lts_20230125::SetProgramUsageMessage(std::__1::basic_string_view<char, std::__1::char_traits<char>>)", referenced from:
      _Init_ext in ext.o
  "absl::lts_20230125::Now()", referenced from:
      operations_research::MPSolver::wall_time() const in linear.o
  "absl::lts_20230125::Duration::operator-=(absl::lts_20230125::Duration)", referenced from:
      operations_research::MPSolver::wall_time() const in linear.o
  "absl::lts_20230125::Duration::operator*=(double)", referenced from:
      Rice::detail::NativeFunction<operations_research::MPSolver, init_linear(Rice::Module&)::$_1, true>::call(int, unsigned long*, unsigned long) in linear.o
  "google::protobuf::TextFormat::PrintToString(google::protobuf::Message const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*)", referenced from:
      Rice::detail::NativeFunction<operations_research::sat::CpModelBuilder, init_constraint(Rice::Module&)::$_40, true>::call(int, unsigned long*, unsigned long) in constraint.o
  "google::protobuf::Arena::AllocateForArray(unsigned long)", referenced from:
      google::protobuf::RepeatedField<int>::GrowNoAnnotate(int, int) in constraint.o
  "google::protobuf::Duration* google::protobuf::Arena::CreateMaybeMessage<google::protobuf::Duration>(google::protobuf::Arena*)", referenced from:
      Rice::detail::NativeFunction<operations_research::RoutingSearchParameters, init_routing(Rice::Module&)::$_4, true>::call(int, unsigned long*, unsigned long) in routing.o
      Rice::detail::NativeFunction<operations_research::RoutingSearchParameters, init_routing(Rice::Module&)::$_5, true>::call(int, unsigned long*, unsigned long) in routing.o
  "google::protobuf::internal::ThreadSafeArena::thread_cache_", referenced from:
      void google::protobuf::RepeatedField<int>::InternalDeallocate<false>() in constraint.o
  "google::protobuf::internal::protobuf_assumption_failed(char const*, char const*, int)", referenced from:
      void google::protobuf::RepeatedField<int>::InternalDeallocate<false>() in constraint.o
  "absl::lts_20230125::flags_internal::FlagImpl::AssertValidType(void const*, std::type_info const* (*)()) const", referenced from:
      operations_research::CppBridge::SetFlags(operations_research::CppFlags const&) in ext.o
  "google::protobuf::internal::ThreadSafeArena::SpaceAllocated() const", referenced from:
      google::protobuf::RepeatedField<int>::~RepeatedField() in constraint.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [ext.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/or-tools-0.10.1 for inspection.
Results logged to /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/extensions/arm64-darwin-22/3.2.0/or-tools-0.10.1/gem_make.out

  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:102:in `run'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:51:in `block in make'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:43:in `each'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:43:in `make'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:42:in `build'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:170:in `build_extension'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:204:in `block in build_extensions'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:201:in `each'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/ext/builder.rb:201:in `build_extensions'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/rubygems/installer.rb:843:in `build_extensions'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/rubygems_gem_installer.rb:72:in `build_extensions'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/source/rubygems.rb:200:in `install'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/installer/gem_installer.rb:54:in `install'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/installer/parallel_installer.rb:155:in `do_install'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/installer/parallel_installer.rb:146:in `block in worker_pool'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/worker.rb:62:in `apply_func'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/worker.rb:57:in `block in process_queue'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/worker.rb:54:in `loop'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/worker.rb:54:in `process_queue'
  /Users/ollym/.rbenv/versions/3.2.1/lib/ruby/3.2.0/bundler/worker.rb:90:in `block (2 levels) in create_threads'

An error occurred while installing or-tools (0.10.1), and Bundler cannot continue.
ankane commented 1 year ago

Hi @ollym, removing the --with-or-tools-dir config should fix the error (installing OR-Tools with Homebrew is no longer needed on Mac ARM as of 0.8.0).