Path: chuka.playstation.co.uk!news From: sosman@terratron.com (Steven Osman) Newsgroups: scea.yaroze.programming.gnu_compiler Subject: Re: Linking Date: Fri, 03 Dec 1999 03:38:18 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 82 Message-ID: <38473a31.380863452@news.playstation.co.uk> References: <8275bv$jq3@scea> NNTP-Posting-Host: 209.27.57.69 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 Antony, I would recommend using something to the effect of: extern u_short Layout1[6]; in the .h file, and putting the code you have written below in bg.c. I am guessing that you #include bg.h in both main.c and bg.c, correct? The problem is that each time a .c file #includes bg.h, they will define a new "copy" of Layout1, hence, your error. As for your latter comment, I'm not certain why u_short Layout1[6]; would work. To me, that looks like you are still redefining it. Maybe it has something to do with the way the linker works/ including statically initialized variables, and all...? (Still, I don't think EITHER should work). On Thu, 2 Dec 1999 20:26:11 -0500, "Antony Arciuolo" wrote: >I have an array to describe a layout (index) for a GsBG. > >I want to explicitly define it in the header of a BG module: > >#ifndef BG_H >#define BG_H > >u_short Layout1[] = >{ >GsCELLtransparentCell, GsCELLtransparentCell, >GsCELLtransparentCell, GsCELLtransparentCell, >GsCELLtransparentCell, GsCELLtransparentCell >}; > >... >#endif > >Now I want to compile using this makefile > > >PROGRAM = test.pxe >PXE_ADDR = 80140000 > ># To Optimize use -O3 instead of -g >OPTIONS = -c -g >LINKER = -Xlinker -Map -Xlinker mapfile.map -Xlinker -Ttext -Xlinker $(PXE_ADDR) >DEPENDENCIES = bg.o main.o > >all: $(PROGRAM) > >$(PROGRAM): $(PROGOBJ) $(DEPENDENCIES) > gcc $(LINKER) $(DEPENDENCIES) -o $(PROGRAM) > >main.o: main.c mainTIMS.h Levels.h > gcc $(OPTIONS) main.c > >bg.o: bg.c bg.h Levels.h > gcc $(OPTIONS) bg.c > >The problem is: > >gcc -Xlinker -Map -Xlinker mapfile.map -Xlinker -Ttext -Xlinker 80140000 bg.o main.o -o test.pxe >main.o(.data+0x0): multiple definition of `Layout1' >bg.o(.data+0x0): first defined here >make.exe: *** [test.pxe] Error 1 > >How can I solve this? It just does not seem to me that it is being defined twice, and if I redeclare Layout1 as: > > >u_short Layout1[6]; > >Everything is fine. Why? > >- Tony > > > >