I compiled the following code as a shared library using g++ -shared ...:
class Foo {
public:
Foo() {}
virtual ~Foo() = 0;
virtual int Bar() = 0;
};
class TestFoo : public Foo {
public:
int Bar() { return 0; }
};
extern "C" {
Foo* foo;
void init() {
foo = new TestFoo();
}
void cleanup() { delete(foo); }
void bar() { foo->Bar(); }
}
The goal is to expose the functionality of my classes (here at least the minimum toy classes as an example) as a simple API Cwith three functions init, cleanupand bar.
When I try to load a shared library (using dyn.loadin R), I get an error message:
unable to load shared library 'test.so':
test.so: undefined symbol: _ZN3FooD2Ev
So it looks like he cannot find the constructor Foo. What am I doing wrong and how can I fix this?
: , jbar! Foo. : _ZN3FooD2Ev? D FooD ?