bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AC_LIB_HAVE_LINKFLAGS: linking with static library on macOS


From: Mohammad Akhlaghi
Subject: AC_LIB_HAVE_LINKFLAGS: linking with static library on macOS
Date: Fri, 24 May 2019 12:02:32 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

Dear Gnulib,

In Gnuastro, we recently changed to using `AC_LIB_HAVE_LINKFLAGS' for all our library dependencies at configure time.

But while testing it on a macOS machine yesterday we came up with the following problem:

The machine only has a static version of one of the libraries in `/usr/local/lib' (which is also the default `--prefix'). So the output of `AC_LIB_HAVE_LINKFLAGS' for that library was a static file (`/usr/local/lib/libcfitsio.a') and configure finished without a problem.

But during Make, we got the following crash from `ranlib' when it was trying to compile Gnuastro's library (which links with libcfitsio):

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive member: .libs/libgnuastro.a(libcfitsio.a) fat file for cputype (7) cpusubtype (3) is not an object file (bad magic number) /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: internal ranlib command failed

The full outputs of `configure' and `make', as well as `config.log' are also attached.

After some investigation, I came up with [1] which says: "The root cause of it is what we provide static libraries on OS X only in fat(Universal binary) format and GNU libtool does not know anything about it. Our recommendation here is to use libtool which is provided by Apple in XCode.".

Previously (when we were simply using `AC_SEARCH_LIBS'), it would set `-lcfitsio' and the linker would go searching in other parts of the system and find the a shared library version of libcfitsio. So it wouldn't crash, but was building with a library that we didn't know about (also not good!)!!!

I wanted to see if know of a solution for such scenarios?

If not, one thing I can currently think of is to add a test within `AC_LIB_HAVE_LINKFLAGS' so when it finds a static library, tries linking it with a test library, and only use the static library if there is no `ranlib' crash.

Thanks a lot in advance,
Mohammad


[1] https://software.intel.com/en-us/forums/intel-integrated-performance-primitives/topic/596272

Attachment: config.log
Description: Text Data

Attachment: configure-terminal.log
Description: Text Data

Attachment: make-terminal.log
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]