2004年7月15日
testlib1.h
int aaa = 0;
testlib1.c
#include "testlib1.h"
testlib2.h
int aaa = 2;
testlib2.c
#include "testlib2.h"
driver.c
#include "testlib1.h"
int main(int argc, char *argv[])
{
return 0;
}
$ gcc -c testlib1.c
$ gcc -c testlib2.c
$ gcc -o driver driver.c testlib1.o testlib2.o
testlib1.o(.data+0x0): multiple definition of `aaa' /tmp/cco28Dy9.o(.data+0x0):
first defined here testlib2.o(.data+0x0): multiple definition of `aaa' /tmp/cco28Dy9.o(.data+0x0):
first defined here collect2: ld returned 1 exit status