[Interest] Problem creating a dll that loads static Qt libraries (in mingw) -> final chapter

Till Oliver Knoll till.oliver.knoll at gmail.com
Thu Jan 19 14:13:04 CET 2012



Am 19.01.2012 um 10:51 schrieb erick oliveira da silva <eosilva2000 at ig.com.br>:

> Hi Folks,
> 
> Just a last update about my problem:
>  
> 1) With mingw at windows, I can't build a shared library exporting a function, using a Qt library statically built ( -static option in configure ). It is strange: if I export a class, the .dll is built suscessfully, and works. If I write and export just a c++ function that contains/uses Qt classes, I get "undefined reference" when I try to link the shared library. 

Depending on your code it *might* be necessary (and hence correct behaviour) to export the /entire/ class!

This might be due to the generated code by moc, which needs also to be exported (and this can only be done by exporting the /entire/ class).

However, this should actually only be "effective" when you actually link /against/ your shared library, not when you try to link your library itself... but I understand your build process already fails at the later point, trying to build the shared lib itself.

You say that it seems to work when using the MS compiler, right? IIRC depending on compiler switches the linker actually might /ignore/ missing symbols and your DLL seems to link fine - unless you actually try to use it (unless you link against another DLL /first/ which provides the missing symbols).

So in the MSVC case: did you actually try to link against your DLL and call the exported method/function from a simple *.exe?

Also as to rule out the very obvious: you DO use two /different/ static Qt versions, one compiled with an MSVC compiler (same version and compiler switches as your DLL, where applicable) and the other compiled with the gcc/MinGW environment (dito for switches) - right? ;)

(Well, you say it works when you export the entire class, so I strongly assume you do.)


Personally I have never used a static Qt lib, so what you observe might indeed be a glitch somewhere (maybe even in the MinGW/gcc).


Cheers, Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120119/cdb4596f/attachment.html>


More information about the Interest mailing list