public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* multiple definition of `main'
@ 2002-01-21  8:51 Devrim Erdem
  2002-01-21 17:56 ` ???
  0 siblings, 1 reply; 2+ messages in thread
From: Devrim Erdem @ 2002-01-21  8:51 UTC (permalink / raw)
  To: gcc-help

Hello,

I am having a problem of multiple definitions which I couldn't figure out.

The full linker is here :

Obj_Linux_IA32/Graphics.a(DynModel.o): In function `Gfx::TestModel 
type_info function':
/vires/devrim/Projects/Fstd/Src/Modules/Graphics/DynModel.hh(.text+0x0): 
multiple definition of `main'
.Obj_Linux_IA32/Graphics.a(Graphics.o)(.text+0x0):/vires/devrim/Projects/Fstd/Src/Modules/Graphics/Graphics.cc: 
first defined here
collect2: ld returned 1 exit status

This happens when I use the class TestModel ( which is in DynModel.hh ). It is true that Graphics.cc has a main but it is definetely not multiply defined.

I had experienced similar problems when I implement a class method in header file out of the class scope without using the "inline" word. Adding inline would fix those. This one makes me clueless. 

Any ideas...?

gcc-2.95.3-124 on SuSE 7.3

Regards.

-- 
Devrim Erdem
-------------------------------------
VIRES Simulationstechnologie GmbH
Oberaustrasse 34
83026 Rosenheim
Germany
phone    +49.8031.463640
fax      +49.8031.463645
email    devrim@vires.com
internet www.vires.com
-------------------------------------


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: multiple definition of `main'
  2002-01-21  8:51 multiple definition of `main' Devrim Erdem
@ 2002-01-21 17:56 ` ???
  0 siblings, 0 replies; 2+ messages in thread
From: ??? @ 2002-01-21 17:56 UTC (permalink / raw)
  To: Devrim Erdem, gcc-help

Including of header file equal to insert the the whole of the header file
into the line where '#include' appeared.
if you have header file myheader.h, mycfile1.c,mycfile2.c:

/*************************myheader.h***********************************/
void myfunction(){printf("a function in a header file without inline");}
/*************************end of
myheader.h***********************************/


/*************************mycfile1.c***********************************/
#include "myhdaer.h"
void main(){}
/*************************end of
mycfile1.c***********************************/

/*************************mycfile1.c***********************************/
#include "myhdaer.h"
void something(){}
/*************************end of
mycfile1.c***********************************/

then mycfile1.c equal to :

void myfunction(){printf("a function in a header file without inline");}
void main(){}

and mycfile2.c equal to:

void myfunction(){printf("a function in a header file without inline");}
void something(){}

when you link the two file together, you will get a multiple definitions
error,
but if myfunction is inlined ,it's ok.
---------------------------------------------------------
1uNCEE
Guo Xuesong
Sohu-inc
phone: +86 13910010559
email: xuesongguo@sohu-inc.com


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Devrim Erdem
Sent: Tuesday, January 22, 2002 12:45 AM
To: gcc-help
Subject: multiple definition of `main'


Hello,

I am having a problem of multiple definitions which I couldn't figure out.

The full linker is here :

Obj_Linux_IA32/Graphics.a(DynModel.o): In function `Gfx::TestModel
type_info function':
/vires/devrim/Projects/Fstd/Src/Modules/Graphics/DynModel.hh(.text+0x0):
multiple definition of `main'
.Obj_Linux_IA32/Graphics.a(Graphics.o)(.text+0x0):/vires/devrim/Projects/Fst
d/Src/Modules/Graphics/Graphics.cc:
first defined here
collect2: ld returned 1 exit status

This happens when I use the class TestModel ( which is in DynModel.hh ). It
is true that Graphics.cc has a main but it is definetely not multiply
defined.

I had experienced similar problems when I implement a class method in header
file out of the class scope without using the "inline" word. Adding inline
would fix those. This one makes me clueless.

Any ideas...?

gcc-2.95.3-124 on SuSE 7.3

Regards.

--
Devrim Erdem
-------------------------------------
VIRES Simulationstechnologie GmbH
Oberaustrasse 34
83026 Rosenheim
Germany
phone    +49.8031.463640
fax      +49.8031.463645
email    devrim@vires.com
internet www.vires.com
-------------------------------------



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-01-22  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-21  8:51 multiple definition of `main' Devrim Erdem
2002-01-21 17:56 ` ???

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).