On Sep 27, 2025, at 14:50, Kenneth Wolcott wrote:
> confused about MacPorts GIMP libraries when using C as a library binding 
> language...
> 
> So I have several GIMP-oriented ports:
> 
> port installed | grep -i gmp
>   gmp @6.3.0_0 (active)
>   p5.34-alien-gmp @1.160.0_0 (active)
>   p5.34-crypt-dh-gmp @0.0.120_0 (active)
>   p5.34-math-bigint-gmp @1.700.300_0 (active)
>   p5.34-math-bigint-gmpz @0.1.800_0 (active)
>   p5.34-math-gmp @2.250.0_0 (active)
>   p5.34-math-gmpf @0.530.0_0 (active)
>   p5.34-math-gmpq @0.670.0_0 (active)
>   p5.34-math-gmpz @0.670.0_0 (active)
>   p5.34-math-prime-util-gmp @0.520.0_0 (active)
>   R-gmp @0.7-5_0 (active)
> 
> So is "gmp" the library or the executable or both? Apparently only the 
> library.  But is it complete?

Using "port contents gmp" I see it contains two libraries, libgmp (for use from 
C or most other languages) and libgmpxx.dylib (for use from C++), and 
associated support files. No executable. I have no reason to believe it's 
incomplete. 

> Apparently I have several gmp C++ bindings (gmp, gmpc, gmpz, gmpq?) but only 
> one C gmp binding (gmp).  So I can get a C++ gmpz binding to work great but I 
> cannot get a C gmpz created (please show me how).

The ports beginning with p5.34- are for use from Perl 5.34, so I don't think 
learning about how it divides up access to the GMP libraries will help you use 
GMP from C. 

Similarly ports beginning with R- are for use from the R language; inapplicable 
here. 

> So, this is why the Pluto GMP library binding is failing; there is no gmpz 
> library to bind to (??)
> 
> I see lots of Perl gmp bindings as ports; where is Perl getting its gmpz from?

Using "nm /opt/local/lib/libgmp.dylib" you can see the names of the symbols in 
the library. I see symbols beginning with gmpf, gmpn, gmpq, gmpz; so these are 
not separate library files; they're part of the one and only libgmp. 

> Here's my attempt to build a Pluto GMP binding:
> 
> #!/bin/bash
> 
> # clang -c -fpic libpluto-gmp.c -I /opt/homebrew/Cellar/gmp/6.3.0/include/
> # clang -O3 -fpic -shared -o libpluto-gmp.dylib libpluto-gmp.o -lgmp -L 
> /opt/homebrew/Cellar/gmp/6.3.0/lib/

If we wanted to try to reproduce this on our systems, where would we get this 
libpluto-gmp.c?

> Here's the results from running the Pluto task code:
> 
> (cd Pluto/Fermat_Numbers; ./fermat_numbers.pluto)
> The first 10 fermat numbers are:
> F₀ = 3
> F₁ = 5
> F₂ = 17
> F₃ = 257
> F₄ = 65537
> F₅ = 4294967297
> F₆ = 18446744073709551617
> F₇ = 340282366920938463463374607431768211457
> F₈ = 
> 115792089237316195423570985008687907853269984665640564039457584007913129639937
> F₉ = 
> 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084097
> 
> Factors of the first 9 Fermat numbers:
> /opt/pluto/v.0.12.0/bin/pluto: ./bignum.pluto:1391: failed to load library 
> './libpluto-gmp.dylib'
> stack traceback:
> [C]: in function 'pluto:ffi.open'
> ./bignum.pluto:1391: in field 'init'
> ./fermat_numbers.pluto:29: in main chunk
> [C]: in ?

This looks like /opt/pluto/v.0.12.0/bin/pluto is trying to dlopen 
libpluto-gmp.dylib from the current directory and doesn't find it. Is 
libpluto-gmp.dylib in the current directory when you run this command?


Reply via email to