Reputation: 5495
I do not understand why ar
gives a warning when it is creating a library.
I do this:
$ cat foo.c
int foo(int a) {
return a + 1;
}
$ clang -c foo.c
$ ar r foo.a foo.o
ar: warning: creating foo.a
$
Is r
the right command to use with ar
? Why do I get the warning?
I am using clang
and FreeBSD
. Not sure if ar
comes from clang
or from FreeBSD
.
Upvotes: 3
Views: 295
Reputation: 58142
If the output file doesn't already exist, you are supposed to use the c
modifier. From the man page:
c
Create the archive. The specified archive is always created if it did not exist, when you request an update. But a warning is issued unless you specify in advance that you expect to create it, by using this modifier.
So try ar rc foo.a foo.o
to silence the warning.
Upvotes: 3