Author Topic: nspire-ld question  (Read 3962 times)

0 Members and 1 Guest are viewing this topic.

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
nspire-ld question
« 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

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: nspire-ld question
« Reply #1 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
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: nspire-ld question
« Reply #2 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 ;)
« Last Edit: December 07, 2010, 05:55:19 pm by fb39ca4 »

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: nspire-ld question
« Reply #3 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?

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: nspire-ld question
« Reply #4 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.
« Last Edit: December 07, 2010, 06:03:30 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: nspire-ld question
« Reply #5 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