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.

C/C++ > Problem about Code Waves

#6854 - dieudunet - Tue Jun 03, 2003 3:24 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

#7016 - mpowell - Fri Jun 06, 2003 7:15 am

Try using g++ instead of gcc as it's specific for compiling CPP code.

#7062 - johnny_north - Sat Jun 07, 2003 5:46 pm

I had this same problem. You MUST surround all of the code in the gbaplayer.h file with the extern"C" compiler directive or your code won't link the C libs to your C++ project:

/****************************************************************
/ GBA Module Player Copyright (c) 2001-2002 Sergej Kravcenko /
/ Version 1.1 sergej@codewaves.com /
****************************************************************/

#ifndef GBAPLAYER
#define GBAPLAYER

#ifdef __cplusplus
extern "C" {
#endif

//all of the header code

#ifdef __cplusplus
}
#endif

#endif