Question about how to compile multiple files with g++

Yen m9142610@student.nsysu.edu.tw
Thu Mar 17 12:11:00 GMT 2005


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



More information about the Gcc-help mailing list