Problem compiling many Rosetta Code Nim programs: could not load: libgmp.dylib
Kenneth Wolcott
kennethwolcott at gmail.com
Wed Jan 1 17:04:43 UTC 2025
Thank you, Brian and Ryan, for your analysis.
Ken Wolcott
On Wed, Jan 1, 2025 at 3:02 AM Ryan Carsten Schmidt <ryandesign at macports.org>
wrote:
> On Dec 31, 2024, at 19:06, Kenneth Wolcott wrote:
> >
> > 3. MacPorts port: nim
> > 4. nimble is the Nim package manager which comes with the nim port.
> > 4. nimble install bignum (seems to successfully install, but I wonder
> if it is silently installing an x86-64 pre-compiled binary??)
> > 5. compile using: nim c ./arithmetic_geometric_mean_calculate_pi
> > 6. execute: ./arithmetic_geometric_mean_calculate_pi
>
> I agree, on my Intel Mac with macOS 12 this produces:
>
> could not load: libgmp.dylib
> (compile with -d:nimDebugDlOpen for more information)
>
> However it succeeds if I run it this way:
>
> DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
> ./arithmetic_geometric_mean_calculate_pi
>
> Computed 25000 digits in 103 ms
> π = 3.141592653589793238...81377399510065895288...
>
> Anytime a program requires you to set DYLD_LIBRARY_PATH or
> DYLD_FALLBACK_LIBRARY_PATH, the developers are doing it wrong.
>
> The gmp nimble module that the bignum nimble module is using evidently
> tries to use the gmp library by dlopening it. On macOS, it is necessary to
> pass the absolute path to the library to be opened, and they are evidently
> not doing that and are only passing the library name. That may be common on
> Linux but it is not done that way on macOS. macOS is not Linux.
>
> Using dlopen at all is not recommended on macOS and has worse performance
> than doing it the "normal" way, which is to link with the dynamic library.
>
> I'm not sure whether the bug is only in the gmp nimble module or is more
> pervasive. In searching for this error, I've found reports of it with other
> libraries as well. It may be a design flaw in nimble or nim that needs a
> central solution.
>
> I did not find a bug report tracking this problem. I found many reports of
> problems like this but they all end with the suggestion to set the
> environment variable, which is just a workaround and not a fix.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20250101/60da54c5/attachment.htm>
More information about the macports-users
mailing list