Linker Errors when trying to refactor and use multiple classes.

MotscoudBun

New Member
OP
Newbie
Joined
Nov 18, 2023
Messages
1
Trophies
0
Age
24
XP
27
Country
United Kingdom
Hey all! First time poster, long time lurker.
I've been starting to learn the Nintendo DS development suite and have been rather comfortable with what I've made so far
(A little platformer prototype)
But I'm at the point I want to refactor the code - seperate things into multiple classes.
Tonight I have seperated the player out of main, however I'm getting linker errors.

/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: main.o: in function `main':
/home/edlyn/nds-examples-20200510/playingaroundextendable/source/main.cpp:126:(.text.startup+0x86): undefined reference to `Character::Character()'
/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /home/edlyn/nds-examples-20200510/playingaroundextendable/source/main.cpp:168:(.text.startup+0xa6): undefined reference to `Character::draw(glImage*)'
/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/13.2.0/../../../../arm-none-eabi/bin/ld: /home/edlyn/nds-examples-20200510/playingaroundextendable/source/main.cpp:134:(.text.startup+0x128): undefined reference to `Character::update(Platform*, int, int, int)'
collect2: error: ld returned 1 exit status

This didn't happen before the refactor, and the majority of the code - has not changed.
I have posted the current version on my github:
Motscoud/NDS-Demo-game/

If anyone can save my sanity, I'll be appreciative, I'm sure it's something small.
 

metroid maniac

An idiot with an opinion
Member
Joined
May 16, 2009
Messages
2,092
Trophies
2
XP
2,708
Country
Functions defined within the body of a class are implicitly inline which means that they won't always be emitted as externally visible symbols.

So just have Character::Character() { ..., void Character::update(Platform platforms[], int num_platforms, int scrollX, int scrollY) { ..., etc inside your .cpp file. You generally shouldn't have a second definition of the same class inside the .cpp file anyway.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Xdqwerty @ Xdqwerty:
    @Psionic Roshambo, the only hard drive i have is the one on my pc
  • Psionic Roshambo @ Psionic Roshambo:
    I had a weird thought, Sega with the Saturn it was a train wreck a pile of chips, but it does kind of fit the design philosophy of Sega at the time.... The Genesis/Sega CD/32X machine was probably loads of fun to program for
  • BigOnYa @ BigOnYa:
    Damn, the new COD coming soon is 310gb on series s/x
    +1
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, I bet a good chunk of the space games have is due to unused content
  • Psionic Roshambo @ Psionic Roshambo:
    310GBs lol ISPs hate this one trick
  • Psionic Roshambo @ Psionic Roshambo:
    DLC will be a svelt 32K download lol
  • BigOnYa @ BigOnYa:
    I think you only get like 425gb on a series s hard drive, so you get 1, 2 next gen games max
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, so you need to have another series s if you wanna play more games?
  • BigOnYa @ BigOnYa:
    Nuh you buy extra HD n add to it, but not cheap
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, how can a console have more than 1 hard drives?
  • MysticStarlight @ MysticStarlight:
    usb expansion? I know the PS4 can do this
  • Xdqwerty @ Xdqwerty:
    @MysticStarlight, oh Yea I recall my PS3 can do that
  • Xdqwerty @ Xdqwerty:
    Modded ofc
  • Xdqwerty @ Xdqwerty:
    Speaking of my PS3 i havent downloaded any games yet bc my wifi is too slow
  • Xdqwerty @ Xdqwerty:
    and also because blackouts here are very common and that could damage the console
  • MysticStarlight @ MysticStarlight:
    Do you have a surge protector or an UPS?
  • BigOnYa @ BigOnYa:
    Yea but to play the next gen games, you must have those games on internal, or buy the official ssd expansion cards, which are expensive
  • Xdqwerty @ Xdqwerty:
    @MysticStarlight, dunno what each one of those are
  • Xdqwerty @ Xdqwerty:
    @MysticStarlight, my PS3 was already modded when my dad bought it for me and my brother
  • MysticStarlight @ MysticStarlight:
    A surge protector is a device that protects your electronics from fluctuations. I recommend having your console plugged into one of those
  • MysticStarlight @ MysticStarlight:
    An UPS is even better because it has an internal battery that keeps your system on even if the power goes out, but it's much more expensive obviously
  • Xdqwerty @ Xdqwerty:
    @MysticStarlight, oh i recall seeing one in some in the houses of some relatives, including my dad's apartment
  • Xdqwerty @ Xdqwerty:
    @MysticStarlight, although whatever device we plug into them stops getting power anyways lol
  • MysticStarlight @ MysticStarlight:
    that's weird
  • Xdqwerty @ Xdqwerty:
    @MysticStarlight, and oh i was talking about ups
    Xdqwerty @ Xdqwerty: @MysticStarlight, and oh i was talking about ups