I have a mixed C / C ++ library.
Outside, it provides a C interface using extern C. Inside there are templates and classes. Creating a library using "ar" did not pose a problem. The file is called libo-client.a.
However, when linking the .a file using gcc (not g ++), I get a lot of errors that look like this:
libo-client.a(mysocket.o):(.rodata._ZTV7mStream[vtable for mStream]+0x10): undefined reference to `__cxa_pure_virtual' ... mysocket.cpp:(.text+0x15ad): undefined reference to `operator new[](unsigned long)' mysocket.cpp:(.text+0x15c1): undefined reference to `operator delete(void*)' mysocket.cpp:(.text+0x167a): undefined reference to `__cxa_allocate_exception' mysocket.cpp:(.text+0x16a6): undefined reference to `__cxa_throw' ...
My compilation / link line is as follows:
gcc $(CFLAGS) $(INCLUDES) test2.c libo-client.a -o test2
Where test2 is my test harness.
This problem does not occur when I use g ++. However, I am going to link this library to a C project that is compiled with gcc. How do I get around this? What is the reason for this?
EDIT:
Despite the fact that I do not use the standard C ++ library, I obviously need some things, such as the new / delete operator, etc., and there are exceptions inside.
I am associating this thing with the Xen hypervisor, so I'm not sure which options I have, but completely rewrite this thing or maybe try to compile Xen with g ++ instead?
source share