Hi,
I am trying to make a wrapper in c so i can compile a program using
c++ code in gcc.
The next setup actually works, but when i try to use it with c++
classes i get "undefined reference to `__gxx_personality_v0' collect2:
ld returned 1 exit status"
WORKING SETUP:
test1a.cpp:
extern "C" int tomroot(int x)
{
int y = x * x;
return y;
}
_____________________________
test1b.c:
#include "stdio.h"
int tomroot(int);
int main() {
int x = 6;
printf("%d\n",tomroot(x));
}
_____________________________
commandline: g++ -c test1a.cpp; gcc -c test1b.c; gcc test1a.o test1b.o
-o test1
FAILING SETUP:
mcc.h:
#ifndef MCC_H
#define MCC_H
class mcc {
public:
int tomroot( int x );
};
#endif
_____________________________
mcc.cpp:
#include "mcc.h"
int mcc::tomroot( int x )
{
int y = x * x;
return y;
};
_____________________________
mccintermediate.cpp:
#include "mcc.h"
extern "C" int intermediatetomroot( int x )
{
mcc temp;
return temp.tomroot( x );
}
_____________________________
mccintermediatetestc.c:
#include "stdio.h"
int intermediatetomroot( int x );
int main()
{
printf("%d\n", intermediatetomroot( 5 ));
}
_____________________________
commandline: g++ -c mcc.cpp mccintermediate.cpp; gcc -c
mccintermediatetestc.c; gcc mcc.o mccintermediate.o
mccintermediatetestc.o -o mccintermediatetestc
which outputs, as mentioned above:
mccintermediate.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
Anybody has a clue ? Suggesting using g++ to compile the c code won't
do me no good, i need a c compiler ( eg gcc ) doing this job.
Thanks in advance, Tom.