This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Question about how to compile multiple files with g++
- From: "Yen" <m9142610 at student dot nsysu dot edu dot tw>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 17 Mar 2005 17:02:08 +0800
- Subject: 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