PDA

View Full Version : Issues with development of DLL library using Qt/Qt Creator



Momergil
10th March 2014, 13:50
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:

10121

How to correct this thing?


Thanks,

Momergil

anda_skoa
10th March 2014, 14:22
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,
_

Momergil
13th March 2014, 18:17
Thanks for the news, anda_skoa! I'll gladly move the things from _global to the unique other header when possible now :)


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" ;)

anda_skoa
13th March 2014, 20:19
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.



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,
_