Message-Id: <199810010003.UAA21629@delorie.com> Comments: Authenticated sender is From: "George Foot" To: dupheraire AT aol DOT com (Dupheraire) Date: Thu, 1 Oct 1998 01:01:14 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT 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