Mail Archives: djgpp/1998/03/27/18:00:56
[mailed & posted]
On Thu, 26 Mar 1998 21:23:43 +0000, Radha Kotamarti
<rkotamar AT u DOT washington DOT edu> wrote:
> I'm experiencing a strange error when I try to compile a file that
> includes one other file located in the local directory (I'm including
> the sources with this posting). Here's how I invoke the compiler and the
> output I'm getting:
>
> [C:/complex_test/complex/complexlib] gcc complex.C -o complexlib.a
That looks like you want to create a library this way. It doesn't work
because gcc tries to create an executable coff/exe file named
"complexlib.a". You should compile your module only:
gcc -c complex.C
(or use gxx/g++ instead)
You will get a "normal" object file (complex.o), which you can link to
directly to your other modules, especially the one containing your
main() function:
gcc main.C complex.o -o program.exe
- this will compile main.C and link it together with complex.o.
If you want to create a library you have to use the program "ar" from
the binutils archive (bnu281b.zip):
ar rvs libcomplex.a complex.o
Now you can link you main.C with that library:
gcc main.C -lcomplex -o program.exe
or
gcc main.C libcomplex.a -o program.exe
Note that the first one (-lcomplex) is the preferred way, but it
requires that you give your library a name _starting_ with "lib".
Regards...
Michael
- Raw text -