Search code examples
cxcodemacosmakefileunix-ar

'illegal option -- U' when running the ar command from a Makefile compiling C code


I am running macOS X Catalina and trying to run the 'Make' file, but it tells me the following:

(base) charliesharpe@MacBook-Pro alterbbn_v2.2 % make

AlterBBN v2.2 - A. Arbey, J. Auffinger, K. Hickerson, E. Jenssen 2019

make  -C src/ libbbn.a
gcc -c -O3 -pipe -fomit-frame-pointer -mtune=native -ffast-math -fno-finite-math-only -fopenmp general.c
ar rcsU libbbn.a general.o; rm general.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar: illegal option -- U
usage:  ar -d [-TLsv] archive file ...
    ar -m [-TLsv] archive file ...
    ar -m [-abiTLsv] position archive file ...
    ar -p [-TLsv] archive [file ...]
    ar -q [-cTLsv] archive file ...
    ar -r [-cuTLsv] archive file ...
    ar -r [-abciuTLsv] position archive file ...
    ar -t [-TLsv] archive [file ...]
    ar -x [-ouTLsv] archive [file ...]

What does this mean?

I am quite new to C so I am not too confident with it all so the more detail about solving this the better. I have Xcode 12.3 and using Macports version of gcc.


Solution

  • This doesn't really have anything to do with make specifically. The Makefile uses the U option to ar which is not supported by BSD ar which macOS uses. You can likely remove the U option from the Makefile without impacting the final program although usually handling these types of options would be the job of a Makefile generation tool such as CMake or autotools.