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

erick oliveira da silva eosilva2000 at ig.com.br
Fri Jan 20 23:04:03 CET 2012


Hi Andreas,

I changed the makefile but it didn't work.

Thanks anyway for all of you. I learnt a lot from you guys.

Best Regards,
Erick

2012/1/20 Andreas Pakulat <apaku at gmx.de>

> On 20.01.12 10:14:09, erick oliveira da silva wrote:
> > Hi Till,
> >
> > Thanks for your reply. I learned a lot with it.
> >
> > I compiled qt library by myself. I download the sources and compiled with
> > gcc-mingw, the same compiler I am trying to build my simple qt shared
> > library now.
> >
> > The function that I would like to export:
> >
> > --- Header : dllfct.h ---------------------------------
> >
> > #ifndef DLLFCT_H
> > #define DLLFCT_H
> >
> > #include <QtCore/qglobal.h>
> > #include <QtGlobal>
> >
> > #if defined(MY_DLL)
> > #define EXPORT  Q_DECL_EXPORT
> > #else
> > #define EXPORT  Q_DECL_IMPORT
> > #endif
> >
> > // function to be imported/exported
> > EXPORT void tstfunc (void);
> >
> > #endif //DLLFCT_H
> >
> > -----------------------------------------------------
> >
> > -- Source File : dllfct.cpp ---------------
> >
> > #include <QString>
> > #include <QDebug>
> > #include "dllfct.h"
> >
> > void tstfunc (void)
> > {
> > QString msg = "Hello";
> >   qDebug(qPrintable(msg));
> > }
> >
> > ---------------------------------------------------------
> >
> > -- Pro file:
> >
> > QT -= gui
> > TEMPLATE = lib
> > CONFIG += qt dll release
> >
> > SOURCES = dllfct.cpp
> >
> > MAKEFILE = Make_QDECL
> >
> > DEFINES += MY_DLL
> >
> > INCLUDEPATH += ./dllQDECL
> > DEPENDPATH += ./dllQDECL
> >
> > HEADERS = dllfct.h
> >
> > --------------------------------
> >
> > and here my output:
> >
> > D:\dllmingw\qt>mingw32-make -f Make_QDECL.Release
> > g++ -c -O2 -frtti -fno-exceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
> > -DMY_DL
> > L -DQT_DLL -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW
> > -DQT_HAVE_S
> > SE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT
> > -I"..\..\qt_static_4.7.4\
> > include\QtCore" -I"..\..\qt_static_4.7.4\include" -I"dllQDECL"
> > -I"..\..\qt_stati
> > c_4.7.4\include\ActiveQt" -I"release"
> > -I"..\..\qt_static_4.7.4\mkspecs\win32-g++
> > " -o release\dllfct.o dllQDECL\dllfct.cpp
> > g++ -Wl,-s -shared -Wl,--out-implib,release\libqtdll.a -o
> release\qtdll.dll
> > rele
> > ase/dllfct.o  -L"d:\qt_static_4.7.4\lib" -lQtCore -lole32 -luuid -lws2_32
> > -ladva
>
> IIRC the correct linker-command for linking a static library needs to be
> the absolute path of the .a file. -L/-l are only used by gcc for shared
> libs. So it seems that qmake generates the wrong Makefile contents, you
> could verify that by copying the line, removing the -L and -lQtCore
> arguments and replace that with something like
> d:\qt_static_4.7.4\lib\libQtCore.a (provided that this file actually
> exists). If that works, you'd have to dive into qmake code or file a
> report with the bugtracker to find out (or have someone else find out)
> why qmake generates these incorrect linker arguments.
>
> Andreas
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120120/ccf7f6d3/attachment.html>


More information about the Interest mailing list