public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compiling and Linking help
@ 2005-11-08  8:31 Djekic Dusan
  2005-11-08  8:43 ` Aseem Rastogi
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Djekic Dusan @ 2005-11-08  8:31 UTC (permalink / raw)
  To: gcc-help

Hello!
I have the the problem related to compiling and linking the following:

a.h
int a( ) { };

b.h
#include a.h
class B { B( ); };

b.cpp
#include "b.h"
B::B( ) { a( ); }

c.h
class C { C( ); };

c.cpp
#include "c.h"
C::C( ) { }

main.cpp
#include "b.h"
#include "c.h"
B b;
C c;


compiling:  g++ -c b.cpp
                 g++ -c c.cpp
                 g++ -c main.cpp

linking:       g++ -o out b.o c.o main.o


Here I get no compilation errors, but do get linking errors stating
multiple definitions of everything regarding a.h. I found out this is
the product of double compiling everything regarding   a.h in b.o and
main.o, but could not find the way how to write proper and simple
Makefile, but to have object files for b, c and main, and afterwards
linked together. Could you help me with this?

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

end of thread, other threads:[~2005-11-09 16:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-08  8:31 Compiling and Linking help Djekic Dusan
2005-11-08  8:43 ` Aseem Rastogi
2005-11-08  8:45 ` Dima Sorkin
2005-11-08  9:54   ` Djekic Dusan
2005-11-08  9:59     ` Aseem Rastogi
2005-11-08 10:03       ` Djekic Dusan
2005-11-08 10:10       ` Djekic Dusan
2005-11-08 10:17         ` Aseem Rastogi
2005-11-08 10:20           ` Djekic Dusan
2005-11-08 10:31             ` Aseem Rastogi
2005-11-08 10:40               ` Djekic Dusan
2005-11-08 15:11 ` John Love-Jensen
2005-11-09 11:28   ` Dima Sorkin
2005-11-09 16:07     ` corey taylor

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).