[Solved] Linking statically against some libs
-
Hello,
sorry for this beginner question but I'm somehow stuck...
I'm playing around with Qt and created a small application which perfectly compiles and runs on Linux. It uses libical and boost. Now I would like to build it on Windows. Installing the libs went smoothly (using MinGW). But now I think QtCreator (or qmake, that is) tries to link dynamically. How can I link to these libs (not Qt!) statically?What makes me wonder is that QtCreator thinks that the (static) libs end with .lib, but their suffix is .a. So, I can't add them via the GUI dialog, but did it manually, for example:
@win32: INCLUDEPATH += $$quote(C:/mylibs/mingw/include)
win32: LIBS += -L$$quote(C:/mylibs/mingw/lib) -llibical@Somewhere I read that CONFIG += static will do the trick, but it doesn't change anything.
So, maybe you can help me with this.
Thanks a lot
Martin -
welcome to devnet
The Qt precompiled versions are always for dynamic linking. You would need to compile Qt by yourself for static linking.
However, beware of the "license issues":http://qt.nokia.com/products/licensing as well.
-
Thanks koahnig. I'm aware of the licensing model. So it isn't possible to link some libs (Qt) dynamically and some others statically? I wasn't aware of this linker restriction (haven't done so much with libs).
But then it would be nice if the build process would copy the dynamic libs into the build-dir so that the .exe can find them (on windows, that is), right?
-
Hello,
Linking some libs statically and Qt dynamically is totally possible. The .a file should be ok as long as you compiled it for Windows or you downloaded windows version. I think Qt Creator has nothing to do with your problem but it's more gcc (or more precisely the linker) which handles your libraries while building. CONFIG += static is for compiling your lib statically not the app.
What messages have you got? Missing references while linking, missing dll when running? -
I only got the message, that the linker couldn't find the lib, e.g.:
@c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -llibboost_date_time-mgw47-mt-1_50@But the .a files are available. If I compile boost also for dynamic linking (.dll.a, if I understand this correctly), the linker finds the lib but links it dynamically.
Maybe I just don't know how to tell qmake that I want to link dynamically?
-
May be not much of help but there is a video tutorial "here":http://www.voidrealms.com/viewtutorial.aspx?id=245 that you can check .
-
Ok, title is edited. The only problem now is that my current MinGW/GCC version (4.7) doesn't seem to fit with the precompiled Qt binaries (MinGW 4.4). But that's a different thing. This one is solved. :)
EDIT: Recompiled Qt 4.8.2 with MinGW GCC 4.7.0 and now everything works.