#23251 - Joe_Sextus - Thu Jul 08, 2004 7:17 pm
Whenever I attempt to compile a source file that calls a member function of a class I get the error
undefined reference to '__gxx_personality_sj0'
does anybody now how to fix this.
Here's my code.
MAIN.CPP
Code: |
#include "Intro.h"
int main (void)
{
CIntro Intro;
Intro.DrawIntro();
return 0;
} //int main (void)
|
INTRO.CPP
Code: |
#include "Intro.h"
CIntro::CIntro(void)
{
} //CIntro::CIntro(void)
CIntro::~CIntro(void)
{
} //CIntro::~CIntro(void)
void CIntro::DrawIntro(void)
{
int a = 1 + 2;
} //void CIntro::DrawIntro(void)
|
Thanks in advance,
-Joe
#23254 - Darmstadium - Thu Jul 08, 2004 8:52 pm
what compiler r u using?
#23260 - Odjnn - Thu Jul 08, 2004 11:29 pm
I found some [url=http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&q=undefined%20reference%20to%20'__gxx_personality_sj0']forum posts[/url] about your specific error and they all seem to relate to a gcc build error, possibily from bugs in the newer releases. This seems to be the most likely, but, you also said the second block of code was Intro.cpp, but Intro.cpp is not included in Main.cpp. Did you include intro.cpp into intro.h? Or did you mistype and the second block is suppose to be intro.h?
If the former, could you show us the contents of Intro.h?
If the latter, then you forgot the class declaration Code: |
class CIntro
{
//private vars
//...
public:
Cintro();
~CIntro();
void DrawIntro();
//...
}
|
#23266 - Darmstadium - Fri Jul 09, 2004 12:42 am
i had problems workin with classes when I was using gcc, then I switched to g++ and my code compiled fine. If you use a batch file like in the PERN project tut, just change the gcc to g++
#23276 - Joe_Sextus - Fri Jul 09, 2004 5:18 am
I am using DevKitAdv r5 Beta3. I have some stuff I write a while back that used classes. And at the time they compiled fine, but now they don't (using gcc, they do with g++) and as far as I know the configuration hasn't changed. I put DevKitAdv on CD so I could use it anywhere and after the last time I formatted my computer I never put it back until here recently.
I only showed Intro.cpp and Main.cpp as an example, there are several files in the project. Here is Intro.h, but the problem has nothing to do with the headers.
Code: |
#ifndef INTRO_H_INCLUDED_12311982
#define INTRO_H_INCLUDED_12311982
//Includes
#include "DataTypes.h"
//Class Definition
class CIntro
{
protected:
public:
CIntro(void);
~CIntro(void);
void DrawIntro(void);
}; //class CIntro
#endif //INTRO_H_INCLUDED_12311982
|
Datatypes.h just defines BYTE, WORD, DWORD, and NULL.
#23290 - poslundc - Fri Jul 09, 2004 2:15 pm
Joe_Sextus wrote: |
I am using DevKitAdv r5 Beta3. I have some stuff I write a while back that used classes. And at the time they compiled fine, but now they don't (using gcc, they do with g++) and as far as I know the configuration hasn't changed. |
Um, what exactly is the problem then? Just use g++. It's what you're supposed to use to compile C++ source.
Dan.
#23296 - tepples - Fri Jul 09, 2004 3:05 pm
Dan is right. Here's why:
In general, "undefined reference" means that the linker can't find a function, such as if you left out a library. The big difference between gcc and g++ is that g++ adds the C++ libraries to the end of the command line when linking the object files to produce a .elf executable.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#23327 - Joe_Sextus - Fri Jul 09, 2004 11:29 pm
I was under the impression that gcc.exe was just a front-end for the various compilers/assemblers in the GCC. That's why I thought my configuration was screwed up.
Thanks,
-Joe
#23329 - poslundc - Fri Jul 09, 2004 11:53 pm
Joe_Sextus wrote: |
I was under the impression that gcc.exe was just a front-end for the various compilers/assemblers in the GCC. |
It is. But C++ doesn't play nice with the other languages. ;)
Dan.