Some strange problem related Qt static library.

  • I have created a static library using already available Qt static libraries like core/gui/network/xml, I included them in my development project and created my static library myLib.lib.

    Now I wanted to write a Qt based test app which will be using my lib but it seems I need to include all those Qt libraries again in my test app, is it correct or I missed something?
    Without including xml and network Qt libs it is giving linker error.

  • I know that if you use the VC compiler, and "link" some static library with other third-party libraries, then there is no need for your application to be linked with those third-party libraries. If you use MinGW compiler, I think it comes in the situation you mentioned. However a static library can not be "linked" with other third-party libraries, only dynamic libraries and applications can be in the true sense in link with other libraries.

  • But I am using Visual Studio compiler.

  • Well, when you compile something static the linker does not include all the symbols in the resulting binary, it usually just picks the ones referenced. So if your library A has references to symbols 1, 2 and 3 of library B only those are included. If your application now references symbol 4, 5 and 6 of library B, but is just linked against A (which has only 1, 2 and 3) you will get an linker error and you will have to link against library B again (so the linker can pull out symbol 4, 5 and 6).

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.