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++ > libgba in C++

#102338 - Philderbeast - Wed Sep 13, 2006 1:19 am

Well I'm verry new to boath C++ and GBA/DS development so be warned this may sound very noobish.

I have been working on creating a basic program for the GBA t get use to the hardware before I try something a little more challangeing.

After reading about 50 million tutorials and downloading several e-books ont boath C++ and GBA dev I started to mess around with the examples to bend then to suit what I was trying to do.

Now all I'm trying to do at this stage is get a background on to the screen. however m getting an error when I attempt to compile it.

the error is as follows:
Code:
linking cartridge
yapg.o: In function `main':
c:/devkitPro/msys/home/philbert/make/src/yapg.cpp(53): undefined reference to `DecodePCX(unsigned char const*, unsigned short*, unsigned short*)'
collect2: ld returned 1 exit status
make[1]: *** [/home/philbert/make/yapg.elf] Error 1
make: *** [build] Error 2


Im assuming its something to do with me using C++ rather than C and that library not reading properly (it works if I make it C, but as im using C++ specific stuff else where I whant to keep it consistant).

If anyone can point me to where I can find some more information i would be most gratefull.

#102341 - sajiimori - Wed Sep 13, 2006 2:05 am

Code:
extern "C"
{
  void DecodePCX(unsigned char const*, unsigned short*, unsigned short*);
}

That's a very creative spelling of "both." ;)

#102343 - Philderbeast - Wed Sep 13, 2006 2:28 am

ok then where do I put that code?

putting it in the C++ file gives me a diffrent error

#102346 - sajiimori - Wed Sep 13, 2006 3:02 am

That's how you should declare the function. Wherever it's declared now, surrounding it with extern "C".

If it's declared in a plain-C header and you don't want to modify the header, surround the #include with extern "C" instead.

#102382 - Philderbeast - Wed Sep 13, 2006 1:12 pm

Thank you very much

that solved it perfectly :)