gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Linker error

#94320 - yayo - Mon Jul 24, 2006 10:55 am

Hi, I've got a project based on one of the templates from the devkitpro. I've added a subdir into base/source dir, so now I've got three files in there. I've changed the makefile so it gets the code compiled under the new created folder. All the files (except warnings) got compiled but the pipeline does'nt link them.

The results are a lot of warnings (sorry, I'll cut/paste them this evening, I'm at work) telling that the functions I've declared and implemented in one of the new files are not included in the final package, which is not created by the way.

The make ends with error: 1 linker error
_________________
http://eduyayo.blogspot.com

#94391 - yayo - Mon Jul 24, 2006 6:38 pm

Hi again, I'm back with the cut'n paste

/funcs.c:2666: undefined reference to `xstrlen'
/funcs.c:2667: undefined reference to `xstrncmp'

I mean that the linker doesn't find my .o files and donno why. My gcc skills are a bit scratched ^^

thanks
_________________
http://eduyayo.blogspot.com

#94392 - Mighty Max - Mon Jul 24, 2006 6:43 pm

Do you include .C functions from within .CPP?

If you do, try extern "C" the includes
_________________
GBAMP Multiboot

#94407 - yayo - Mon Jul 24, 2006 7:48 pm

Nono, I use pure C for now.

And still crashes! I've solved hundreds of compilation problems on a lib I'm trying to port and now got stuck with the linker. I'm sure is something stupid I'm not doing and damn it to hell!!!
_________________
http://eduyayo.blogspot.com

#94462 - tepples - Mon Jul 24, 2006 9:59 pm

xstrlen? xstrncmp? Never heard of them. What is the difference between them and standard strlen and strcmp?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#94479 - yayo - Mon Jul 24, 2006 11:27 pm

These are mine, simply functions ^^. They differ in the comparisons they made
_________________
http://eduyayo.blogspot.com

#94500 - josath - Tue Jul 25, 2006 2:16 am

yayo wrote:
These are mine, simply functions ^^. They differ in the comparisons they made


Is the linker linking all the correct .o files?
If your commandline is hidden, and you cannot see what is being linked, you may have to edit the makefile...in mine it's in arm9/Makefile, around line 120,
Code:

$(ARM9ELF)      :       $(OFILES)
        @echo linking $(notdir $@)
        @$(LD)  $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@

and remove the single @ from infront of the $(LD) line

Then, when you run make, you should get something like:
Code:
linking birds2.arm9.elf
arm-eabi-g++  -specs=ds_arm9.specs -g -mthumb -mthumb-interwork -mno-fpu -Wl,-Map,.map bird.raw.o bullet.raw.o font.pal.o font.raw.o man.raw.o ouch.raw.o poop.raw.o power.raw.o power_hp.raw.o power_shot.raw.o power_spd.raw.o shot.raw.o shot2.raw.o sprites.pal.o squak1.raw.o squak2.raw.o squak3.raw.o main.o   -L/home/davidr/ds/devkitarm//libnds/lib -lnds9 -o /lvm/shared/ds/ds/birds2/arm9/birds2.arm9.elf