views:

99

answers:

1

I have an ordinary abstract class that has a couple of pure virtual methods. The class itself is a part of the shared library. The compilation of the shared library itself is OK. But when the library is linked to another program that has another class deriving from the abstract one in the shared library and defining the pure virtual methods, I get the following linker error.

I compile like this..:

g++ -I../path/to/the/library main.cpp derived.cpp -L../path/to/the/library -lsomename -o shared 

The linker error is:

libsomename.so: undefined reference to `AbstractClass::method()'

It's like the abstract class cannot access its pure virtual methods, but I do not try to make any instance of the abstract class anywhere in the library.

What could be the problem?

+1  A: 

When defining abstract classes you have to make all functions virtual and also end with =0 i.e:

class DPReporterI
{
public:
    virtual uint32 getProviderCount()=0;
    virtual uint32 getProviderId(uint32 index)=0;

    virtual uint32 getLastRate(uint32 id)=0;
    virtual void getName(uint32 id, char* buff, uint32 size)=0;
};

Make sure you do this and it should work.

Lodle
everything done that way from the very beginning...
JTom
can you post the code thats giving you the error than please.
Lodle