Inheriting an abstract class from a precompiled-library, in a precompiled libarary

Started by
1 comment, last by Wymsical 22 years, 2 months ago
Hi, I have a slight problem. Let class Resource be an abstract class in a static library called "Util". Resource implements pure virtual: WriteResource and non-virtual WriteBaseResource. Now let class BitmapResource inherit Resource in a static library called "Graphics2D". I _believe i did something like this before in MSVC i just linked to "Util" when compiling "Graphics2D". However now that i''m using kdevelop (which uses gcc) its giving me problems. compiling the .a file (the static library) its fine, but when it comes time to use it, it complains of an undefined refernece to Resource::WriteBaseResource() So my question is: How would i implement this type of architecture where both "Util" and "Graphics2D" are static libraries that will be later used? Thx in advance The wymsical wyvern
Advertisement
Sounds like this should be right. The class is defined in the .h file in your library, and the non-virtual function should be defined in your library''s object code. Are you sure you''re linking in the library, not just including its headers?
yep

i did a test program, i made class foo:

class foo {
foo() {}
~foo() {}

static int i;
};

in foo.cpp:
int foo::i = 0;

i compiled that into a .a file with somethign like:
ar foo.o libfoo.a

then i made:
class foobar : public foo {

foobar() { int junk = i; }
~foobar();
};

compiling foobar into libfoobar.a is fine,
but as soon as i make an app:

void main( void ) {

foobar aFooBar;
}

it complains and i''m 100% sure that i link to libfoo.a and libfoobar.a

This topic is closed to new replies.

Advertisement