Hi, On Thu, Apr 24, 2025 at 10:36:05AM -0700, Alan Snyder wrote: > This code should also build a dynamic library, but it does not:
I don't have any insight regarding specific details of cross compiling dynamic libraries on mac OS. But I did notice the following: > export CFLAGS="-arch x86_64" > ./configure --host=x86_64-apple-macos10.10 --target=x86_64-apple-macos10.10 > --enable-shared [...] > I also noticed something odd in the configure log: > > configure:4614: checking whether we are cross compiling > configure:4622: gcc -o conftest -arch x86_64 conftest.c >&5 > configure:4626: $? = 0 > configure:4633: ./conftest > configure:4637: $? = 0 > configure:4652: result: no > > It fails to recognize cross compilation because the cross compiled > executable actually runs on macOS. This behaviour is expected, because you have not specified the --build parameter to configure. If you do not specify --build, then configure will only enter cross compilation mode if the programs it compiles cannot be run. So if you are intending to cross compile: ./configure --build=aarch64-apple-macos10.10 --host=x86_64-apple-macos10.10 is the correct invocation (--target should rarely be used, it is for a so-called "Canadian Cross" build---cross compiling a cross compiler. (I have no idea if aarch64-apple-macos10.10 is the appropriate build triplet for your system but most packages probably don't care too much) > Just out of curiosity, why do I need to set CFLAGS? Doesn’t the host > and target provide enough information? Configure scripts normally rely on the user to tell them what to do, especially when it comes to things like which compiler to use and with what options. Since you specified --host=x86_64-apple-macos10.10 configure will try to run x86_64-apple-macos10.10-gcc first. That obviously failed, but it found plain "gcc" and is using that. Normally configure will print a warning when cross compiling with an unprefixed compiler, because such compilers are not normally cross compilers. But since you did not specify --build and thus configure does not think you are cross compiling, it did not print the warning. Hope that helps, Nick