delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/27/18:00:56

From: michael DOT mauch AT gmx DOT de (Michael Mauch)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Strange compile-time error
Date: Fri, 27 Mar 1998 17:29:33 +0100
Organization: Gerhard-Mercator-Universitaet -GH- Duisburg
Lines: 46
Message-ID: <6fgk58$1ta$1@news-hrz.uni-duisburg.de>
References: <351AC75F DOT E4329B26 AT u DOT washington DOT edu>
NNTP-Posting-Host: ppp103.uni-duisburg.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

[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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019