delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/30/20:03:43

Message-Id: <199810010003.UAA21629@delorie.com>
Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT ox DOT ac DOT uk>
To: dupheraire AT aol DOT com (Dupheraire)
Date: Thu, 1 Oct 1998 01:01:14 +0000
MIME-Version: 1.0
Subject: Re: Linking all my files together?
Reply-to: mert0407 AT sable DOT ox DOT ac DOT uk
CC: djgpp AT delorie DOT com
X-mailer: Pegasus Mail for Win32 (v2.42a)

On 30 Sep 98 at 21:13, Dupheraire wrote:

> Just came across another problem that had bugged me when using this compiler
> before.  For some reason it is trying to compile and link the two different
> .cpp files together that I have made.  1st program is-

[snipped]

> When I try to compile the 2nd one I get these errors:
> Error:hello.o: In function 'main'
> Error:hello.cpp(.text+0x8): multiple definitions of 'main'
> Error:exer1_1.o(.text+0x78):exer1_1.cpp:first defined here
> 
> Know what is wrong?

It's impossible to say for sure unless you tell us what command
line you used.  To compile the second program I'd type:

    gcc -c hello.cpp

plus other miscellaneous options such as -O2, -g, etc.  That 
will compile it to the object file `hello.o'.  To link that 
with the necessary libraries you should use gxx because it is a 
C++ program:

    gxx -o hello.exe hello.o

plus any other options you want to use.

Or you can compile and link in one step:

    gxx -o hello.exe hello.cpp

(followed by both your compilation switches and linking 
switches).

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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