This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
link error: multiple definition of
- From: zhjin <zj0ch at sina dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 17 Oct 2002 13:05:30 +0800
- Subject: link error: multiple definition of
hi
this is my code under redhat linux 8.0.
//a.h
#ifndef ah
#define ah
int i;
void add();
#endif
//a.cpp
#include "a.h"
void add(){
i++;
}
//c.cpp
#include "a.h"
int main(){
i = 100;
add();
return 0;
}
g++ -c a.cpp success
g++ c.cpp a.o
error: a.o(.bss+0x0): multiple definition of 'i'
/tmp/cc0q7tmK.o(.bss+0x0): first defined here
collect2: ld returned 1 exit status.
can someone help me to solve problem?
thanks.