Mail Archives: djgpp/1997/04/02/03:04:28
On Tue, 1 Apr 1997, Skye wrote:
> gcc -c libtest.cc -o libtest.a
>
> [copy libtest.a file to djgpp\lib dir]
>
> the program is: prog.cc [includes libtest.h]
>
> gcc -c prog.cc -o prog.o
> gxx -o prog.exe prog.o -ltest
> [run prog.exe and it should work]
It might work for you, but it's sure an incorrect way to do that! The
.a suffix is for object *libraries*, not object *files*. Telling gcc
to put the object code into libtest.a doesn't make libtest.a a
library, it is still an object file, albeit renamed. Libraries should
be created and maintained using the `ar' program. Here's how you
create a library with a single object file in it:
gcc -c libtest.cc -o libtest.o
ar rvs c:/djgpp/lib/libtest.a libtest.o
(of course, use your pathname of DJGPP lib directory instead of
c:/djgpp/lib). Note that you can omit the "-o libtest.o" part, gcc
does this by default anyway.
And here's how you put more than one object file into a library:
gcc -c libt1.cc
gcc -c libt2.cc
gcc -c libt3.cc
ar rvs c:/djgpp/lib/libtest.a libt1.o libt2.o libt3.o
If you want to know how to maintain object libraries, and what that
`rvs' thing on the `ar' command line is, please read the docs of `ar';
you can't *really* expect to understand this without reading the docs,
can you?. Here's how to read the docs of `ar':
info binutils ar
- Raw text -