or-tools-ruby icon indicating copy to clipboard operation
or-tools-ruby copied to clipboard

Fedora images not supported

Open aisler-ma opened this issue 10 months ago • 1 comments

Fedora is not supported by the gem and does not build.

It is not quite as simple as adding the fedora builds form the Github. Fedora zips only ship with 64-bit shared libs. Thus, we need to copy them as well and add the lib64 path to the build path.

Find a suggested Patch below:

Index: ext/or-tools/vendor.rb
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ext/or-tools/vendor.rb b/ext/or-tools/vendor.rb
--- a/ext/or-tools/vendor.rb	(revision 3dede323ead82db9d88c9e7d60f6c8e5d0248620)
+++ b/ext/or-tools/vendor.rb	(date 1741682905323)
@@ -45,6 +45,12 @@
   elsif os == "arch" && !arm
     filename = "or-tools_amd64_archlinux_cpp_v#{version}.tar.gz"
     checksum = "18c1d929e2144e9d9602659ea2fa790bd2a150f72c32c38a97f571839816d132"
+  elsif os == "fedora" && os_version == '40' && !arm
+    filename = "or-tools_amd64_fedora-40_cpp_v#{version}.tar.gz"
+    checksum = "ba595e2a9c86e23f559d1be17984ab4cfe56599bb0decd1f5e5b6c4008464023"
+  elsif os == "fedora" && os_version == '41' && !arm
+    filename = "or-tools_amd64_fedora-41_cpp_v#{version}.tar.gz"
+    checksum = "44e3ea31924ae1893a669c4ccf46b5efaf2d37157c0417a9b8038568e9e7c1fb"
   else
     platform =
       if Gem.win_platform?

@@ -144,6 +151,13 @@
     next if file.include?("libprotoc.")
     FileUtils.mv(File.join(extract_path, file), File.join(path, file))
   end
+
+  # Fedora images onyl provide 64 bit libs
+  FileUtils.mkdir(File.join(path, "lib64"))
+  Dir.glob("lib64/lib*{.dylib,.so,.so.*}", base: extract_path) do |file|
+    next if file.include?("libprotoc.")
+    FileUtils.mv(File.join(extract_path, file), File.join(path, file))
+  end
 end
 
 # export
Index: ext/or-tools/extconf.rb
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ext/or-tools/extconf.rb b/ext/or-tools/extconf.rb
--- a/ext/or-tools/extconf.rb	(revision 3dede323ead82db9d88c9e7d60f6c8e5d0248620)
+++ b/ext/or-tools/extconf.rb	(date 1741683139633)
@@ -15,6 +15,7 @@
 if inc || lib
   inc ||= "/usr/local/include"
   lib ||= "/usr/local/lib"
+  lib64 ||= "/usr/local/lib64"
   rpath = lib
 else
   # download
@@ -22,6 +23,7 @@
 
   inc = "#{$vendor_path}/include"
   lib = "#{$vendor_path}/lib"
+  lib64 = "#{$vendor_path}/lib64"
 
   # make rpath relative
   # use double dollar sign and single quotes to escape properly
@@ -32,7 +34,7 @@
 # find_header and find_library first check without adding path
 # which can cause them to find system library
 $INCFLAGS << " -I#{inc}"
-$LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} ")
+$LDFLAGS.prepend("-Wl,-rpath,#{rpath} -L#{lib} -L#{lib64} ")
 raise "OR-Tools not found" unless have_library("ortools")
 
 create_makefile("or_tools/ext")

aisler-ma avatar Mar 11 '25 09:03 aisler-ma

Sorry in case this is obvious for most people here, but in case anyone is trying to install or-tools gem on Fedora:

You can do it by installing or-tools library via Homebrew on Linux. Then you do:

gem install or-tools -- --with-or-tools-dir=/home/linuxbrew/.linuxbrew

Or if you use a Gemfile:

bundle config build.or-tools --with-or-tools-dir=/home/linuxbrew/.linuxbrew

Tested on Fedora 43. It would probably work on most distros as well.

lucasfais avatar Nov 11 '25 17:11 lucasfais