Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: fb39ca4 on December 07, 2010, 04:40:38 pm

Title: nspire-ld question
Post by: fb39ca4 on December 07, 2010, 04:40:38 pm
What is going on here?

Code: [Select]
$ make
nspire-gcc -Os -Wall -W -c sprites.c
nspire-ld  main.o utils.o game.o graphics.o sprites.o -o particles.elf
sprites.o:(.bss+0x0): multiple definition of `tank'
game.o:(.bss+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [particles.tns] Error 1
Title: Re: nspire-ld question
Post by: calc84maniac on December 07, 2010, 04:44:03 pm
It looks like you declared a global variable called tanks in sprites.c when there was already a global variable called tanks in game.c
Title: Re: nspire-ld question
Post by: fb39ca4 on December 07, 2010, 04:53:43 pm
Odd ... I never declared anything called tank in game.c. Changing the name in sprites.c worked, though.
Thanks for the help!

Also, I noticed your respect was at +84 ;)
Title: Re: nspire-ld question
Post by: fb39ca4 on December 07, 2010, 05:56:04 pm
Sorry for the double post, but the problem is back again.
Now, after I changed tank to tanksprite in sprites.c and game.c, I get the same error. I am not using a header file for sprites.c, just putting #include "sprites.c" at the top of game.c. Could this be why?
Title: Re: nspire-ld question
Post by: calc84maniac on December 07, 2010, 06:00:08 pm
Ah yeah, you probably shouldn't be including a .c file. The makefile compiles sprites.c separately, so essentially you are including the sprites.c code twice in the whole project. If you really want to include code, make it a .h file or something.

Edit:
After taking a closer look at the Makefile, I suppose it'll only compile sprite.c separately if you have sprite.o after OBJS in the Makefile. I might be wrong, though.
Title: Re: nspire-ld question
Post by: willrandship on December 07, 2010, 06:08:32 pm
why not change sprites.c to sprites.h? It shouldn't matter (I think), but no program is perfect :P