Date: Wed, 2 Apr 1997 10:49:41 +0300 (IDT) From: Eli Zaretskii To: Skye cc: djgpp AT delorie DOT com Subject: Re: Can't link non standard library. FAQ not enough. In-Reply-To: <334156A0.2FD@iname.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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