I'm trying something spooky here. I'm trying to write C++ programs, compiled with GNU's g++, but without a dependency on libstdc++ :) but it seems that I need that for even the most basic things need it.
A libstdc++ with a configurable feature set would be acceptable.
The command I use is
g++ -nodefaultlibs -fno-rtti -fno-exceptions -lc
Without libstdc++, I get:
undefined reference to `operator delete(void*)'
undefined reference to `operator new(unsigned int)'
undefined reference to `vtable for __cxxabiv1::__class_type_info'
undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
undefined reference to `__cxa_pure_virtual'
These aren't in libc, so is there a really light libstdc++ that implements just these things?
My test code which I want to build this way currently looks like this:
#include <stdio.h>
template <class T>
class X
{
public:
T a;
};
class A1
{
public:
virtual void f() = 0;
virtual ~A1() {}
};
class A2 : public A1
{
public:
virtual void f() {};
virtual ~A2() {}
};
class Y
{
public:
~Y() {}
};
int main()
{
X<int> A;
X<float> B;
Y *C = new Y;
A.a = 12;
B.a = 2.3;
printf("A: %d; B: %f\n", A.a, B.a);
A2 *a2 = new A2;
a2->f();
return 0;
}