On 01/17/2012 04:54 AM, ext Till Oliver Knoll wrote:It means "add these values to this variable unless they are already
> I don't know what the *= operator is supposed to do, even though I think
> it exists.
there". In pseudocode:
for each value (list) {
if (!variable.contains(value))
variable.append(value)
}
Or for an example:
FOO = bar # FOO contains (bar)
FOO += bar # FOO contains (bar, bar)
FOO *= foo bar # FOO contains (bar, bar, foo)
What you want is something like this (replace XXX with your library's name):
> On another note, Qt provides some "cross-platform" macros which expands
> to that __declspec stuff on Windows and to "nothing" on most other
> platforms. Can't remember its name right now, but I thing it's defined
> in the global namespace in qt.h or qt_global.h or something...
#include <QtCore/qglobal.h>
#if defined(Q_OS_WIN)
# if defined(QT_NODLL)
# undef QT_MAKEDLL
# undef QT_DLL
# elif defined(QT_MAKEDLL)
# if defined(QT_DLL)
# undef QT_DLL
# endif
# if defined(QT_BUILD_XXX_LIB)
# define Q_XXX_EXPORT Q_DECL_EXPORT
# else
# define Q_XXX_EXPORT Q_DECL_IMPORT
# endif
# elif defined(QT_DLL)
# define Q_XXX_EXPORT Q_DECL_IMPORT
# endif
#endif
#if !defined(Q_XXX_EXPORT)
# if defined(QT_SHARED)
# define Q_XXX_EXPORT Q_DECL_EXPORT
# else
# define Q_XXX_EXPORT
# endif
#endif
Then you define QT_BUILD_XXX_LIB when building your library.
--
Lincoln Ramsay - Senior Software Engineer
Qt Development Frameworks, Nokia - http://qt.nokia.com/
_______________________________________________
Interest mailing list
Inte...@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
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).
So you're talking about functions in a namespace or global ones I guess?
Since it sounds like you already have a stripped-down example, how about
posting the code and your .pro file (or whatever else you're using for
building)? Maybe we can point you to your error directly.
Andreas
Hi Till,Depending on your code it *might* be necessary (and hence correct behaviour) to export the /entire/ class!
In my case, I unfortunatelly really need to export functions, not classes. And the same program works in Linux with gcc.
Count yourself lucky. There is one more such platform, which has taken the
worst of what Windows had to offer, namely this:
> (Side-note: there is another, I think older mechanism besides the
> "__declspec" approach: to provide an explicit "export table" (*.def ?).
> Refer to the MSDN documentation. But I prefer the __declspec approach, as
> it is "closer tied with the actual code", IMHO easier to maintain.)
That platform is called Symbian.
See
https://qt.gitorious.org/qt/qt/blobs/master/src/s60installs/bwins/QtCoreu.def
and
https://qt.gitorious.org/qt/qt/blobs/master/src/s60installs/eabi/QtCoreu.def
(and others).
On the other hand, there are certain advantages of doing it the Windows way.
I've just posted two blogs asking for some of those advantages to be brought
over to Linux.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
Am 20.01.2012 um 07:14 schrieb erick oliveira da silva <eosil...@ig.com.br>:
> Hi Till,
>
> ...
> CONFIG += qt dll release
Oops, not sure, but I think that's the bugger: can't remember right now the exact meaning of 'dll', but I think this refers to how *Qt* was built (and not how your code is to be build - that is controlled via the TEMPLATE variable) - I think this let's you choose which Qt version to link against, the static or the dynamic one (which off course must both be available, in the proper PATH etc.).
So refer to the qmake docs again and try without 'dll' (followed by a 'make distclean' etc.).
Cheers, Oliver
Maybe you should do so before posting comments that you're not quite
sure of ;) The template only tells you wether to build an app or a
library (or a subdir), the CONFIG += dll or CONFIG += static tells qmake
wether you want a shared lib or a dll.
That being said, it might still be the cause of the problems, since not
all linkers might support linking a static library into a shared one
IIRC (Thiago please correct me if I'm talking nonsense here).
And even those that do will only take the symbols that the shared
library uses, so if you then link an app against the shared lib and
expect it to automatically get all Qt symbols from the shared lib that
won't work either.
Andreas
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
We're talking about Windows here, why would I know? :-)