Mail Archives: djgpp/1998/09/30/20:03:43
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 -