Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtC doesn't call .lib file generating
QtWS25 Last Chance

QtC doesn't call .lib file generating

Scheduled Pinned Locked Moved Qt Creator and other tools
7 Posts 2 Posters 1.5k Views
  • 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.
  • A Offline
    A Offline
    amigo421
    wrote on last edited by
    #1

    I need to create one SUBDIRS type project with a number of dll sub-projects and one console app to test them (for some reasons I can't use unit tests project type).
    So I've created these projects and added library projects into console one from context menu - add library

    MSVC2013 64 bit

    however a linker shows me an error:
    :-1: error LNK1104: cannot open file '<plugin_x>.lib'
    where plugin_x is a one of library projects

    so seems QtC didn't add into library projects a generating .lib files (import library for a linking with dll)

    is this known issue of QtC or I'm doing something wrong?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What is the exact problem with unit tests ?

      Can you show your project pro files ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amigo421
        wrote on last edited by
        #3

        found the solution in vc compiler documentation

        that was because I've only created empty projects:
        dll project and console project (and added dll as a library into console)

        .lib file has not been generated because of project was empty and nothing to export (and link)
        added __declspec(dllexport) to class definition and .lib file was generated and correctly linked with console application

        P.S. I know that export classes is a bad practice and we have to prefer the export of plain functions instead
        but that was a client's requirement

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Oh yes, I've been bitten by that one when changing from static to dll...

          You can have a look at Qt's macro to help you export your classes in a cross platform way.

          It really depends on your use case. Take Qt for example, is it exporting only functions ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            amigo421
            wrote on last edited by
            #5

            I don't use Qt lib here, just a QtC,
            in other hand , this piece of code can be unportable and be built MSVC only.
            you see this - very unportable solution - using class exporting , but that is a client's requirement

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You don't need to use specifically these macros but you can write your own based on them so that you're future proof (client's requirement can unpredictably change)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                amigo421
                wrote on last edited by SGaist
                #7

                I'm using something typical, looks working for me

                #ifdef EXP_STL
                #    define DECLSPECIFIER __declspec(dllexport)
                #    define EXPIMP_TEMPLATE
                #else
                #    define DECLSPECIFIER __declspec(dllimport)
                #    define EXPIMP_TEMPLATE extern
                #endif
                EXPIMP_TEMPLATE template class DECLSPECIFIER std::basic_string<char>;
                

                where EXP_STL is defined for dll and undefined for exe

                the only issue I faced some time ago is an exporting std::list of std::unique_ptr
                unique_ptr has move init semantics but list requires copy ctor
                I was using emplace_back for elements filling up and that was working for single project but for the sharing this object between dll and exe (function in dll returns this list to the caller from exe)
                like this:
                EXPIMP_TEMPLATE template class DECLSPECIFIER std::list<std::unique_ptr<my_class>>;

                raise the error - something about deleted copying ctor of unique_ptr, it'd look reasonable in case of list using
                but here - the declaration only!
                I can't understand why - this is the only declaration. if I remove declspec this will be built correctly….

                [edit: Added missing coding tags: 3 ` before and after SGaist]

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved