Results 1 to 4 of 4

Thread: Issues with development of DLL library using Qt/Qt Creator

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Issues with development of DLL library using Qt/Qt Creator

    Hello!

    I have two questions regarding the doing of C++ libraries using Qt and Qt Creator and its implementation into a Qt project.

    1º: I learned with the YouTube channel VoidRealms that, when you do a DLL library using Qt, two header files appear: one directly related to the library (with its name), and another, with _global on its name, and both of them should be included in the project in order to use the methods included on that library (static linking), while the dll should be included in the .pro file by the LIBS section. Is there another way of using the dll library in static way that don't need to include the _global header?

    2º: All times when I create a DLL library to link statically and that includes on itself a (major) class, when I include it on my project (in the way described above) and compile, a series of warning messages appear (what only occurr in the last MingW version I downloaded, which is probably 4.8). The following image is a print screen with the messages I get from a particular project of mine, mLogger:

    dll.jpg

    How to correct this thing?


    Thanks,

    Momergil
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Issues with development of DLL library using Qt/Qt Creator

    You don't need two headers. If you have only one public header you can also add the export/import macros to that header.
    It is just customary to split the macro definition into a separate header, because a library often has more than one public header and then you can just include the macro definition one in each of them.

    The import/export macro definition is required to get symbol visibility right. Depending on platform and compiler settings, symbols such as classes or functions can be "hidden" by the compiler, i.e. only visible within the library itself but not to the program linking the library.
    Naturally you want the symbols of your public API to be visible, hence the need to mark them for export.

    Since you mentioned static linking a couple of times: this has nothing to do with DLLs, a concept which has "Dynamic Linking" even as part of its name!

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Momergil (13th March 2014)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Issues with development of DLL library using Qt/Qt Creator

    Thanks for the news, anda_skoa! I'll gladly move the things from _global to the unique other header when possible now

    Quote Originally Posted by anda_skoa View Post
    Since you mentioned static linking a couple of times: this has nothing to do with DLLs, a concept which has "Dynamic Linking" even as part of its name!
    Sorry if I used a misleading terminology... By "static" I just mean "Not at runtime"
    May the Lord be with you. Always.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Issues with development of DLL library using Qt/Qt Creator

    Quote Originally Posted by Momergil View Post
    Thanks for the news, anda_skoa! I'll gladly move the things from _global to the unique other header when possible now
    That has always been possible.

    Quote Originally Posted by Momergil View Post
    Sorry if I used a misleading terminology... By "static" I just mean "Not at runtime"
    Yes, static linking means that the library doesn't have to be loaded at runtime.
    DLLs always have to be loaded at runtime, that's the D in DLL.

    A static library is not a DLL and also doesn't need export macros on its symbols.

    Cheers,
    _

Similar Threads

  1. QT creator with Maemo issues in building
    By rg4gp in forum Newbie
    Replies: 0
    Last Post: 11th September 2012, 21:19
  2. Replies: 2
    Last Post: 19th February 2011, 12:26
  3. Replies: 0
    Last Post: 17th March 2010, 23:52
  4. QT Creator Linking issues
    By sgrant327 in forum Qt Programming
    Replies: 14
    Last Post: 16th December 2009, 16:42
  5. Replies: 1
    Last Post: 13th August 2009, 17:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.