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.

Coding > Compiling Code Waves

#6847 - dieudunet - Tue Jun 03, 2003 1:04 pm

I got a C++ error while compiling my code with use of Codewave

using this makefile :

PATH=E:\Data\gba\devkitadv\bin

as start.s -o start.o

gcc -nostartfiles -Wall -mcpu=arm7tdmi -ffreestanding -fomit-frame-pointer -fverbose-asm -fpeephole -Wl,-Map,bin.map,-Ttext=0x08000000,-Tdata=0x03000000 -O3 -o sorcere.elf start.o

sorcere.cpp ./data/module.o ./data/module1.o ./data/menusnd.o ./GBAPlayerGCC.a -lm

objcopy -O binary sorcere.elf sorcere.gba



It do not work , i got this error message about start.o

start.o: In function `data_copy':

start.o(.text+0x114): undefined reference to `PlayerMain'

/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o: In function `PlayerMain(
)':

/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x69d4): undefined reference to `MP_InitArm(unsigned char)'
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x69e0): undefined
reference to `MP_PlayModuleArm(unsigned char const*, unsigned char)'
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x69e8): undefined
reference to `MP_SetVolumeArm(unsigned char)'
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o: In function `main':
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x6b14): undefined
reference to `MP_InitArm(unsigned char)'
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x6b20): undefined
reference to `MP_PlayModuleArm(unsigned char const*, unsigned char)'
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x6b28): undefined
reference to `MP_SetVolumeArm(unsigned char)'
/cygdrive/d/DOCUME~1/matthieu/LOCALS~1/Temp/ccM4EO4j.o(.text+0x6b48): undefined
reference to `MP_UpdateArm()'
/cygdrive/e/Data/gba/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/libgcc.a(__m
ain.o): In function `__do_global_dtors':
__main.o(.text+0x74): undefined reference to `__EH_FRAME_BEGIN__'
/cygdrive/e/Data/gba/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/libgcc.a(__m
ain.o): In function `__do_global_ctors':
__main.o(.text+0x100): undefined reference to `__EH_FRAME_BEGIN__'
collect2: ld returned 1 exit status




but if i change my code to only use c function ( not c++ ) the compilation work fine.
but my code use a lot of pointer and must be compile as a cpp file.

could someone tell me what i would change to compile my cpp code with this start.o....


thank you

#6859 - tepples - Tue Jun 03, 2003 6:23 pm

When a C++ program calls functions, it normally expects them to be other C++ functions. However, Code Waves mod player is a C library. To tell the compiler that Code Waves mod player uses C calling conventions, do this:
Code:
extern "C" {
#include "codewavesmodplayer.h"  /* or whatever it's called */
}

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#6868 - Jason Wilkins - Tue Jun 03, 2003 8:37 pm

This gets me a lot too. I am tempted to write a patch to ld which makes it say 'Undefined reference to C++ function' instead of just 'Undefined reference to funtion' if it is a mangled C++ name instead of a plain C name.

That way, I will notice when I forget to add the extern "C"
_________________
http://devkitadv.sourceforge.net

#7006 - einhaender - Fri Jun 06, 2003 2:09 am

Iam having difficulties with setting up Codewaves as well. My make file looks like:

as ./codewaves/gcc/start.s -o ./codewaves/gcc/start.o

gcc -mthumb-interwork -nostartfiles -Wall -mcpu=arm7tdmi -ffreestanding -fomit-frame-pointer -fverbose-asm -fpeephole -Wl,-Map,./codewaves/gcc/bin.map,-Ttext=0x08000000,-Tdata=0x03000000 -O3 -o sprite.elf reik_sprite.c ./codewaves/gcc/start.o ./codewaves/data/module.o ./codewaves/data/module1.o ./codewaves/data/menusnd.o ./codewaves/GBAPlayerGCC.a

objcopy -O binary sprite.elf sprite.gba


The Compiles says:
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/bin/ld: Warning: ./codewaves/gcc/start.o does not support interworking, whereas reik_sprite.elf does
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/bin/ld: Warning: ./codewaves/data/module.o does not support interworking, whereas reik_sprite.elf does
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/bin/ld: Warning: ./codewaves/data/module1.o does not support interworking, whereas reik_sprite.elf does
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/../../../../arm-agb-elf/bin/ld: Warning: ./codewaves/data/menusnd.o does not support interworking, whereas reik_sprite.elf does
./codewaves/gcc/start.o: In function `jump_intr':
./codewaves/gcc/start.o(.text+0x230): undefined reference to `PlayerMain'
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/interwork/libgcc.a(__main.o): In function `__do_global_dtors':
__main.o(.text+0x80): undefined reference to `__EH_FRAME_BEGIN__'
/cygdrive/c/devkitadv/bin/../lib/gcc-lib/arm-agb-elf/3.0.2/interwork/libgcc.a(__main.o): In function `__do_global_ctors':
__main.o(.text+0x114): undefined reference to `__EH_FRAME_BEGIN__'
collect2: ld returned 1 exit status



I have no idea how to fix that. Anyone can help?