V
vlbel
I'm trying to do the following:
1) The main program consists of
------------ a.h ------------
class A
{
public:
virtual ~A(){}
virtual void b();
};
------------ a.cpp -----------
#include "a.h"
void A::b()
{}
------------ main.cpp ------------
#include <dlfcn.h>
#include <iostream>
using namespace std;
int main()
{
void* handler = dlopen( "../lib/lib.so", RTLD_LAZY );
if( !handler )
{
cout << "Bad" << endl;
cout << dlerror() << endl;
}
}
-----------------------------------
2) Loadable library:
---------------- lib.cpp --------------------
#include "a.h"
class C : public A
{
public:
C() : A(){}
};
extern "C" A* maker()
{
return new C();
}
----------------------------------------------
Compiles ok (gcc 4.1.0, SUSE Linux), but running the program I get:
.../lib/lib.so: undefined symbol: _ZN1A1bEv
What's the matter? nm shows that symbol is defined (in a.o)
1) The main program consists of
------------ a.h ------------
class A
{
public:
virtual ~A(){}
virtual void b();
};
------------ a.cpp -----------
#include "a.h"
void A::b()
{}
------------ main.cpp ------------
#include <dlfcn.h>
#include <iostream>
using namespace std;
int main()
{
void* handler = dlopen( "../lib/lib.so", RTLD_LAZY );
if( !handler )
{
cout << "Bad" << endl;
cout << dlerror() << endl;
}
}
-----------------------------------
2) Loadable library:
---------------- lib.cpp --------------------
#include "a.h"
class C : public A
{
public:
C() : A(){}
};
extern "C" A* maker()
{
return new C();
}
----------------------------------------------
Compiles ok (gcc 4.1.0, SUSE Linux), but running the program I get:
.../lib/lib.so: undefined symbol: _ZN1A1bEv
What's the matter? nm shows that symbol is defined (in a.o)