Static Library for Windows developer



  • Hello
    I am creating my pure c++ library using the following link
    http://msdn.microsoft.com/en-us/library/ms235627.aspx

    -is this the right way for creating the library ?
    -can i use this library in both Qt Application and Visual studio without any problem?
    -can i do change my library if any made after creation the lib?
    -or is there any better way to create library so that it can be used by window c++ developer using any tool/IDE?



  • Hello
    I am creating my pure c++ library using the following link
    -is this the right way for creating the library ?

    This is the right way to create a static library, yes.

    -can i use this library in both Qt Application and Visual studio without any problem?

    I'm not sure to understand fully your question: you can link any application (Qt, non Qt) against this lib. The only requirement is that the application must be built with Visual Studio as well (and maybe the same version for static libs, although I'm not sure about this).

    -can i do change my library if any made after creation the lib?
    -or is there any better way to create library so that it can be used by window c++ developer using any tool/IDE?

    You can change it and recompile it (i.e. recreating it), but then you will have to recompile every single application using it.

    You can go with a shared library to remove the requirement that any using application must be recompiled, but then you have to face the dll limitations (C interface, etc.).



  • Thanks for respond.

    My Question was if i create a static lib using MSVS then can i use it inside Qt Application using Qt Creator and any other Qt/MSVS like C++ tool.

    Which one is better .lib or .dll ?



  • OK, so the answer to your first question is yes, you can.

    Which one is better is a bit trickier... As you may know, shared libraries on windows have (according to me) some limitations:

    • only exported symbols can be used, i.e. you need to add some keywords here and there in order to be able to use your functions
    • exported function must have pure C signature (i.e. no overloading allowed, no by-reference arguments)
    • I never tried to export classes on windows, therefore I won't comment on this.

    On the other hand static libraries allow you to use any code (which can be real C++, classes, overloads, etc.) you want in the application which uses them. The drawback is that since it is linked to your application at compile time, a new version of the library requires a recompilation of every application which is using the library.

    This is why most of the people use static libraries for their core classes and creates shared libraries to give to the end-users (the shared libraries being linked against the static ones).


Log in to reply
 

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