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,089
Trophies
2
XP
2,681
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
  • K3Nv2 @ K3Nv2:
    Too bad Hitler didn't make camps for immigrants oh wait
  • Psionic Roshambo @ Psionic Roshambo:
    Isn't the latest method for slim like self right?
  • Psionic Roshambo @ Psionic Roshambo:
    Like a 1 wire mod?
  • K3Nv2 @ K3Nv2:
    Still two wire with resistor if you don't count the 7 wire pc probes cause hardware likes a good probing
    +1
  • BigOnYa @ BigOnYa:
    2 wires left on motherboard, 7 temp soldered to a flasher, then removed after flashed
  • K3Nv2 @ K3Nv2:
    Technically don't even have to remove it could just keep it on
    +1
  • K3Nv2 @ K3Nv2:
    I don't really mess with hard mods due to neuro issues
  • realtimesave @ realtimesave:
    I tried to get a slim on a black friday once, but they ran out of stock for the $100 one
  • realtimesave @ realtimesave:
    many ages ago
  • BigOnYa @ BigOnYa:
    You can find them $50-75 nowdays if catch a deal
  • K3Nv2 @ K3Nv2:
    Still remember grabbing this ps4 slim on black Friday for $200 when the msrp was still around 300
    +1
  • BigOnYa @ BigOnYa:
    I went to auction at a mom/pops video game store few months ago that was closing, and bought 11 slims for $200, 1 was DOA but 10 work fine. so hella deal. Already rgh3'ed 8 of them. But most younger kids don't even want anymore, unless it plays stupid "fortnight", or newer shit.
  • K3Nv2 @ K3Nv2:
    Think I'm gonna use my giftcard balance on a nice pair of headphones but $100 is still limited
  • K3Nv2 @ K3Nv2:
    Soundcore q30s are nice but they leak so much sound it sounds like speakers
  • Psionic Roshambo @ Psionic Roshambo:
    Ken spend the 100 on a gun and skii mask, wait for a jogger at the park jewelry money and headphones!
    +1
  • K3Nv2 @ K3Nv2:
    If only Amazon sold guns
  • K3Nv2 @ K3Nv2:
    Fucking dick heads think it's a bad idea to get a gun 2 days later
  • BigOnYa @ BigOnYa:
    Wait, I thought you were the dickhe...nvm
  • K3Nv2 @ K3Nv2:
    I got balls on my chin and two dicks on my forehead sir
    +1
  • BigOnYa @ BigOnYa:
    Sorry, no offense there double dickhead chinballs.
  • K3Nv2 @ K3Nv2:
    Chicks still love it
    +1
  • BigOnYa @ BigOnYa:
    "Mommy, look, what is that?". "That's your soon to be daddy."
  • K3Nv2 @ K3Nv2:
    That you'll only see once
    +1
    K3Nv2 @ K3Nv2: That you'll only see once +1