Unlike Linux, GMP library is not present on Windows system by default,
and it is common practice for applications to ship their dependencies.
So I made following changes to make it easier for FriCAS to use GMP
on Windows.

First, this patch bundles libgmp-10.dll (mingw64 version) in our
Windows CI binary.

Second, this patch changes loading logic on Windows to:
try system version of libgmp-10.dll first, (if user has installed
msys2 for example), if fails, try to load our bundled GMP version
instead.

- Qian

diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 24974593..ae576313 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -35,6 +35,7 @@ jobs:
       run: |
         rm ../build/target/x86_64-w64-mingw32/bin/fricas
         mv ../build/target/x86_64-w64-mingw32 FriCAS-windows-x86_64
+        cp /mingw64/bin/libgmp-10.dll FriCAS-windows-x86_64/lib/
zip -r FriCAS-windows-x86_64-${{ github.sha }}.zip FriCAS-windows-x86_64
     - name: Upload Windows binary
       uses: actions/upload-artifact@v3
diff --git a/src/lisp/num_gmp.lisp b/src/lisp/num_gmp.lisp
index 371d91cf..b58001e0 100644
--- a/src/lisp/num_gmp.lisp
+++ b/src/lisp/num_gmp.lisp
@@ -824,12 +824,16 @@
           (symbol-function 'orig-isqrt))
     (sb-ext:lock-package "COMMON-LISP")))

+(defun load-gmp-lib ()
+    #-:WIN32 (ignore-errors (|quiet_load_alien| "libgmp.so") t)
+    #+:WIN32 (if (ignore-errors (|quiet_load_alien| "libgmp-10.dll") t)
+                 t
+                 (ignore-errors (|quiet_load_alien|
+ (BOOT::make-absolute-filename "/lib/libgmp-10.dll")) t)))
+
 (defun init-gmp(wrapper-lib)
     (if (not *gmp-multiplication-initialized*)
-        (if (ignore-errors (|quiet_load_alien|
-                            #-:WIN32 "libgmp.so"
-                            #+:WIN32 "libgmp-10.dll"
-                            ) t)
+        (if (load-gmp-lib)
             (if (ignore-errors
                     (|quiet_load_alien| wrapper-lib) t)
                 (progn

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/d9990b37-a527-4915-a2ce-0d4cdbb774d8%40gmail.com.

Reply via email to