cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
7,382 Views
Registered: ‎02-22-2008

Problem: error `__gxx_personality_sj0' in c++ with classes

Jump to solution

Hello,

 

I'm trying to get a very simple test program working in c++ on a Spartan 3E starter board.

I want to use classes so I have to use c++.

 

The following code works:

 

 

#include <stdio.h>

class Car
{
private:
int nb;
public:
Car(int number)
{
nb = number;
}
~Car() {};
int GetNumber()
{
return nb;
}
};

int main()
{
int val = 0;

xil_printf("testing %d\n",123);
Car bmw(val);
val = bmw.GetNumber();
//xil_printf("testing %d\n",val);
return 0;
}

 

But when I discomment   ' //xil_printf("testing %d\n",val); '

I get the error: 

 

main.o: In function `main':
/cygdrive/c/Xilinx/Now_Testing/TestSDK/SDK_projects/testOSplus/Debug/../main.cpp:26: undefined reference to `__gxx_personality_sj0'

 

I can't solve the problem, and I don't have that much knowledge about C compilers (gcc, g++, ...), libraries, ....

 

Can someone help me? if you need more information, just ask.

 

Thanks

 

 

Message Edited by jmaes on 11-08-2009 09:58 AM
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Visitor
Visitor
9,164 Views
Registered: ‎02-22-2008

I've solved it!

 

I read somewherefor AVR microcontroller:


  • The operators new and delete are not implemented, attempting to use them will cause the linker to complain about undefined external references. (This could perhaps be fixed.)

 

  • Some of the supplied include files are not C++ safe, i. e. they need to be wrapped into
     extern "C" { . . . } 
    (This could certainly be fixed, too.)

 

  • Exceptions are not supported. Since exceptions are enabled by default in the C++ frontend, they explicitly need to be turned off using -fno-exceptions in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0.

So the first thing I did, was deleting the destructor (to avoid any reference to a delete command). And it worked!

 

Thanks anyway :)

 

 

View solution in original post

0 Kudos
3 Replies
Highlighted
Xilinx Employee
Xilinx Employee
7,370 Views
Registered: ‎08-02-2007

Hi,

 

This issue can be overcome by changing the file extension from '.C' (uppercase) to '.c'(lower case).

 

Thanks. 

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Visitor
Visitor
7,349 Views
Registered: ‎02-22-2008

Hmm, I'm not so sure I understand....

Because I want classes, I'm using c++. So the name of my main file is "main.cpp", with cpp in small letters.

 

So I can't solve the problem that way, unless you were referring to something else?

 

(extra: I had the same problem in standalone v2.0, als in xilkernel 4.0)

 

Thanks for responding

0 Kudos
Highlighted
Visitor
Visitor
9,165 Views
Registered: ‎02-22-2008

I've solved it!

 

I read somewherefor AVR microcontroller:


  • The operators new and delete are not implemented, attempting to use them will cause the linker to complain about undefined external references. (This could perhaps be fixed.)

 

  • Some of the supplied include files are not C++ safe, i. e. they need to be wrapped into
     extern "C" { . . . } 
    (This could certainly be fixed, too.)

 

  • Exceptions are not supported. Since exceptions are enabled by default in the C++ frontend, they explicitly need to be turned off using -fno-exceptions in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0.

So the first thing I did, was deleting the destructor (to avoid any reference to a delete command). And it worked!

 

Thanks anyway :)

 

 

View solution in original post

0 Kudos