Linking errors when subclassing

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Aug 22 02:32:26 UTC 2012


I'm asking this in context of automatically generating a wrapper
library for use of the library in another language. If I use the
MP4::File classes in C++ everything works fine, e.g.:

int main()
{
    using namespace TagLib;
    MP4::File* f = new MP4::File("C:\\file.mp4");
    MP4::Properties* props = f->audioProperties();
    int length = props->length();

    printf("length in minutes/secs: %d:%d\n", length / 60, length % 60);
    return 0;
}

But if I subclass an internal class, such as MP4::File::Atom I get a
linker error:

using namespace TagLib;
class Foo : MP4::Atom
{
public:
    Foo() : MP4::Atom(NULL) { }
};

int main()
{
    Foo* bar = new Foo();
}

C:\DOCUME~1\Andrej\LOCALS~1\Temp\ccsdMVNe.o:main.cpp:(.text$_ZN3FooC1Ev[__ZN3FooC1Ev]+0x15):
undefined reference to `TagLib::MP4::Atom::Atom(TagLib::MP4::File*)'

I can see in the libtag.dll that Atom classes aren't exported, which
explains the linker errors. Atom classes are documented as internal,
so that makes sense. Is there any way for me to either:
1. Enable exporting of these classes to DLLs so I can subclass without
errors, or
2. Somehow retrieve a list of header files which should never be
directly included by user code?

I have a codegenerator which wraps every C++ class with a mirrored
class in the target language but I can ignore internal classes which
shouldn't be wrapped and use void* if necessary. I just have to know
which header files/classes need to be ignored. How exactly does cmake
figure out which classes are not to be exported to the DLL?


More information about the taglib-devel mailing list