This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
howto define _gxx_personality wthout -libstdc++ option?
- From: "Polevoy, IgorX" <igorx dot polevoy at intel dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 23 Dec 2002 15:44:48 +0200
- Subject: howto define _gxx_personality wthout -libstdc++ option?
Hi,
I'm compiling library that should give a C interface to the outside word,
but has C++ code inside.
The end is that library will be able to link with C programs, as well as
with C++ programs.
While it worked with previous version of gcc it has problem with gcc 3.2.
the following example explains the problem:
************** file foo.h ************
#ifndef _FOO_H
#define _FOO_H
#ifdef __cplusplus
extern "C" {
#endif
int fooFunc();
#ifdef __cplusplus
}
#endif
#endif
************** file foo.c ************
#include "foo.h"
class Foo{
public:
Foo(){}
~Foo(){}
int getFoo(){ return i; }
private :
int i;
};
extern "C" int fooFunc()
{
Foo f;
return 1;
}
************** file foom.c ************
#include "foo.h"
#include <stdio.h>
int main()
{
return fooFunc();
}
************** makefile ************
all: lib prog
lib: foo.cpp
g++ -c -o foo.o foo.cpp
ar rcv libfoo.a foo.o
ranlib libfoo.a
prog: foom.c
gcc foom.c libfoo.a
************** ************
Result:
gcc foom.c libfoo.a
libfoo.a(foo.o)(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [prog] Error 1
QUESTION is how I could force the definition of __gxx_personality_v0 for
the STATIC
library, without explicit linking with libstdc++ ? I know that if I build
shared library, like this
g++ -shared -Wl,-h libfoo.so.1.0 -o libfoo.so.1 foo.o
it will work OK...
Regards,
Igor.