Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Static Library for Windows developer

    C++ Gurus
    2
    4
    1670
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • IamSumit
      IamSumit last edited by

      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?

      Be Cute

      1 Reply Last reply Reply Quote 0
      • JohanSolo
        JohanSolo last edited by JohanSolo

        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.).

        `They did not know it was impossible, so they did it.'
        -- Mark Twain

        1 Reply Last reply Reply Quote 0
        • IamSumit
          IamSumit last edited by

          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 ?

          Be Cute

          1 Reply Last reply Reply Quote 0
          • JohanSolo
            JohanSolo last edited by

            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).

            `They did not know it was impossible, so they did it.'
            -- Mark Twain

            1 Reply Last reply Reply Quote 0
            • First post
              Last post