GP32 C++ Probs With Mrmirko's - New/delete/unheritance


no_skill

gp2x! bananas! mayhem! mayham!
Joined
Jan 9, 2004
Messages
734
Age
37
Location
Austria
Website
72dpiarmy.com
hi,

i've spent a whole day porting SuperMarioWar to the gp32 using mrmirko's sdk.

i've replaced all pc dependant code, but now i've got a problem:

how can i enable new/delete and inheritance in mrmirko's sdk?

here's an example:

i've changed cpp.cpp from example.cpp to this:

Code:
// written 2004 Mirko Roller   mirko@mirkoroller.de
// This is the c++ part
// modfied by no_skill to show the c++ problems

#include "gp32.h"
#include "cpp_prototypes.h"
#include "cpp.h"

using namespace std;

class basis {
public:
   int wert;
    basis() {}
    basis(int wert) {this->wert=wert;}
    virtual int get_private() { return wert;}
};

class plum : public basis{
public:
	plum(int wert) {this->wert=wert;}
    int get_private() { return wert * 30;}
};


int calling_cpp() {

   basis *pluto = new plum(300);
   int i = pluto->get_private();
   delete pluto;
   return i;

}

Code:
cpp.o(.text+0x10): In function `calling_cpp':
: undefined reference to `operator new(unsigned long)'
cpp.o(.text+0x34): In function `calling_cpp':
: undefined reference to `operator delete(void*)'
cpp.o(.gnu.linkonce.r._ZTI4plum+0x0): undefined reference to `vtable for
iv1::__si_class_type_info'
cpp.o(.gnu.linkonce.r._ZTI5basis+0x0): undefined reference to `vtable for
biv1::__class_type_info'
collect2: ld returned 1 exit status

thanks in advance, no_skill
 
Well, after we talkedt at irc, I made this little cpp example, now it works with new and delete but still fails to link with inheritance.

As I'm only ussing templates at the moment this is enough for me.

As a suggestior for MrMirko, I would prefer that all .h would have
Code:
#ifdef __cplusplus
extern "C" {
#endif

        // stuf here
      
#ifdef __cplusplus
}

So we could get rid of cpp_prototipes.h that can get desincronized.




P.D: can't attach file...
P.D: If I cant find it I'll post the code here...
 
thanks for your great help in icq una-i!

i thought about it and i think the inheritance problem comes not from mrmirko's sdk - i think the windows compiler kit causes it.

i'm going to build my own arm g++ kit and compile mrmirkos sdk on it. i hope that helps.

do you know where i can get the latest arm gcc/g++ version from? (preferably + some std libs).
 
I finally found out how to use C++ with MrMirko's SDK! :)

First you can't call gp_* functions from C++ code, but that's easy to fix, but as soon as you use new/delete or inheritance in your C++ code the makefile from MrMirko's SDK will produce ugly errors (undefined reference to new, vtable stuff, etc)

here's the new example.c++:
http://www.gp32world.co.uk/uploads/files/d...example.c++.zip

and here's what needs to be done:
change that in your makefile:
Code:
LD  = arm-elf-g++

and change your includes to this:
Code:
#include "gp32.h"
#include "cpp_prototypes.h"

thanks to una-i, nin, aquafish, svolli and everyone else who helped me getting a c++ gp32 devenv working :)
 
Nice!!! I didn´t notice about the LD option, I send MrMirco a hack to work whith noew/delete, but now you got the key that's outdated...


P.D: how did you put the attachmentt... I tried on may first post but it was noto possible :confused:
 
the atachment is on gp32world. i'm moderator there.

now that this is done i hope to have a working beta of supermariowar ready this evening.
 
Back
Top