gfortran-for-macOS icon indicating copy to clipboard operation
gfortran-for-macOS copied to clipboard

Issue with library linking

Open pharmpk opened this issue 2 years ago • 2 comments

I'm having issues building (and distributing) my app written fortran (probably 77). If I link with LIB = -static-libgfortran -static-libgcc -static-libstdc++ I get an error dyld[87254]: Library not loaded: /usr/local/gfortran/lib/libquadmath.0.dylib Referenced from: /usr/local/bin/boomer

Update LIB = -static-libgfortran -lSystem libquadmath.0.dylib seems to work with Monterey macOS 12.3

Update 28 April 2022

LIB = -static-libgfortran gives error ld: library not found for -lm

My PATH includes /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/gfortran/lib:/opt/X11/bin:/Library/Apple/usr/bin: Any suggestions? Thanks, David Bourne

pharmpk avatar Apr 25 '22 18:04 pharmpk

  • What machine do you have (Intel or Apple Silicon)?
  • What macOS/Xcode/command-line tools versions?
  • What gcc/gfortran version have you downloaded?

fxcoudert avatar May 08 '22 09:05 fxcoudert

Hi FX

On May 8, 2022, at 3:22 AM, FX Coudert @.***> wrote:

• What machine do you have (Intel or Apple Silicon)?

The desktop Mac that I use to compile my fortran program is a 2017 iMac - Intel

• What macOS/Xcode/command-line tools versions?

Monterey 12.3.1, Xcode 13.3.1 (no extensions),

Xcode 13.3.1 Build version 13E500a

• What gcc/gfortran version have you downloaded?

These are the current settings that seem to work with the PATH ’adjustment' gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/local/gfortran/libexec/gcc/x86_64-apple-darwin21/11.2.0/lto-wrapper Target: x86_64-apple-darwin21 Configured with: ../gcc-11.2.0/configure --prefix=/usr/local/gfortran --with-gmp=/Users/fx/devel/gcc/deps-static/x86_64 --enable-languages=c,c++,fortran,objc,obj-c++,d --build=x86_64-apple-darwin21 --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --enable-libphobos --without-build-config Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.2.0 (GCC)

echo $PATH /Users/db/opt/anaconda3/bin:/Users/db/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/gfortran/lib:/Library/TeX/texbin:/Applications/Little Snitch.app/Contents/Components:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/lib:

Make file uses

F77 = /usr/local/bin/gfortran LL = /usr/local/bin/gfortran LIB = -static-libgfortran -lSystem libquadmath.0.dylib

— I just now recompiled with

LIB = -static-libgfortran

My program worked in the source folder as ./boomer

— I airdropped it to my M1 laptop

After removing gfortran it worked too.

M1 laptop, macOS 12.3.1, Xcode 13.3.1 (just now installed the command-line tools for this version)


On my older laptop with macOS —10.15.7 (Catalina), no gfortran installed at the moment.

The version I have to download failed with

boomer Reason: no suitable image found. Did find: /usr/local/gfortran/lib/libgcc_s.1.dylib: code signature in (/usr/local/gfortran/lib/libgcc_s.1.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed. /usr/local/gfortran/lib/libgcc_s.1.dylib: stat() failed with errno=1 Abort trap: 6

I airdropped the version I compiled just now on my desktop machine to my older laptop and now works.

I should go through the signing, notarizing step and upload to my server for a final test.

— This didn’t work

Downloaded application on my desktop machine gave an error

dyld[46426]: Library not loaded: /usr/local/gfortran/lib/libquadmath.0.dylib Referenced from: /usr/local/bin/boomer Reason: tried: '/usr/local/gfortran/lib/libquadmath.0.dylib' (no such file), '/usr/lib/libquadmath.0.dylib' (no such file) zsh: abort boomer (

Apparently looking for /usr/lib/libquadmath.0.dylib in /usr/lib which isn’t in my PATH

The other two laptops failed with the same error and also looking for libgcc

— Next try using LIB = -static-libgfortran -static-libgcc

Works from desktop and from both laptops after airpdrop.

Still works from both laptops after sign/notorize via airdrop

Downloaded from server. M1 laptop worked OK. Catalina laptop didn’t work

On this laptop the pkg size was 2,107,951 versus 2,244,452 on desktop and M1 laptop before and after trip to the server- curious.

Hmm, I zipped the pkg file and put it on the server.

Downloaded to the Catalina laptop, unzipped, size = 2,244,452 and it ran without complaints.

Looks like I need to go back to zipping the files before uploading.

I may have it all working, maybe just lucky configurations, maybe break next time I try.

Happy to try other options.

Thanks for your help. I hope this is useful…

David Bourne

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

pharmpk avatar May 08 '22 19:05 pharmpk