Home > Mobile >  gcc-10-ar thinks the invalid "." option is being passed to it
gcc-10-ar thinks the invalid "." option is being passed to it

Time:05-06

I'm compiling a game using the Source Engine. When I run make, after a while the archiver tool complains about an invalid option ".":

/usr/bin/ar: invalid option -- '.'

this happens with every archiver I have installed: gcc-10-ar, llvm-10-ar, and busybox ar.

The command the makefile is trying to run is:

gcc-ar-10 ../lib/public/linux32/raytrace.a ./obj_raytrace_linux32/release/raytrace.o ./obj_raytrace_linux32/release/trace2.o ./obj_raytrace_linux32/release/trace3.o

I don't use the archiver tool often, but this looks like a valid command to me. Normally the issue with those is that a dash is being prepended which makes the archiver tool think whatever is following it are the "mini options" like -lm

In my case there aren't any dashes at all. I think the . is from the path but that should be interpreted as a file path and not a command-line argument.

CodePudding user response:

The first argument to ar is supposed to be one or more characters indicating the operation to perform (optionally prefixed with -) and modifiers to this operation.

If you want to create a new archive from the object files, you probably want rcs, which asks ar to insert the listed files into the archive with replacement (r), create the archive if necessary (c) and to create an index for the archive (s).

So for example:

gcc-ar-10 rcs ../lib/public/linux32/raytrace.a ./obj_raytrace_linux32/release/raytrace.o ./obj_raytrace_linux32/release/trace2.o ./obj_raytrace_linux32/release/trace3.o

I assume that ar is giving you the error since it tries to interpret the first . of the first argument as one of these operation instructions.

See also man ar.


As for the linked repository (although I have no experience with it and this is just an observation based on looking at one file in it): It seems that the Makefile expects AR, if it is specified in the environment, to include not only the path to the executable, but also the above-mentioned options (see this line setting a default value).

This is not what is usually expected from the AR environment variable, so this is unconventional. A workaround is to add the rcs argument directly to the environment variable, e.g. if AR is already set in the environment as usual:

AR="$AR rcs" make

instead of

make

Don't set AR globally with these options, since other typical Makefiles will be confused by it.

  • Related