This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question about how to compile multiple files with g++


Hi, 
I have a problem to compile multiple files together using GNU g++, so please 
everybody give 
me a help, thanks! 

We assume there are five files: 

main.cpp : the main function 
a.h      : the header file of class A 
a.cpp    : the definition of class A 
b.h      : the header file of class B 
b.cpp    : the definition of class B 

In the program, main.cpp uses class A (thus including a.h) and class A uses 
class B (thus including b.h). 

So, how do I compile this program to generate the objective file? 

I tried to use the following command, but it feedbacked the error "undefined 
reference to ~(objects in class A and B)". 
command: g++ -Wall -O2 -s main.cpp

ps. running platform: FreeBSD/i386 system 
    compiler: gcc version 3.2.1 

Yen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]