Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Static library linking
Hello guys, :)
I would like to link the libraries in my qmake file statically, especially for windows! I tried everything I know and I googled it, but the solutions I found didn't work. Could anyone tell me what's wrong with my qmake file?
Project created by QtCreator 2011-05-05T14:45:42
QT += core gui
QT += opengl
DEPENDPATH += ../../libsrc
INCLUDEPATH += ../../libsrc
DEPENDPATH += ../../fft
INCLUDEPATH += ../../fft
TARGET = BlochSim
TEMPLATE = app
CONFIG += warn_off
CONFIG += static
SOURCES += main.cpp
HEADERS += mainwindow.h
unix:LIBS += -lrt
unix:LIBS += -lm
unix:LIBS += -lpthread
unix:LIBS += -lgsl
unix:LIBS += -lgslcblas
win32:DEPENDPATH += ../../libsrc/gsl/gsl-win-1.8
win32:DEPENDPATH += ../../libsrc/gsl/gsl-win-1.8/lib
win32:INCLUDEPATH += ../../libsrc/gsl/gsl-win-1.8/include
win32:LIBS += -L../../libsrc/gsl/gsl-win-1.8/lib
win32:LIBS += -L../../libsrc/gsl/gsl-win-1.8/bin
win32:LIBS += -llibgsl
win32:LIBS += -llibgslcblas
So after linking statically I expect to be able to execute the program just by having the executable run alone... but it keeps complaining that it doesn't find libgsl.dll. Any ideas?
Thank you for any efforts :-)
are you sure, you have a version of libgsl for static linking?
How can I know that?
I copied gsl libraries beside the executable, and I got an error with QtCored4.dll... which means, even Qt libraries are not statically linking!
Have you made a complete build from the qt source package with static flag for configure?
The qt distribution does not contain static libraries.
I'm using QtCreator. Doesn't it do that automatically if I set the correct flags in qmake?
Does this mean that I always have to have QtCored.dll and some other dlls for Qt with my programs???
koahnig last edited by
No, QtCreator does not generate static Qt libraries automatically.
You have to compile Qt with static in configure as suggested by Gerolf.
Even without the static libraries you do not need to have Qt dlls with your programs. Typically it is assumed that someone receiving your program has already Qt dlls installed.
If you install QtCreator, you have no libraries (it#s only the IDE)
If you install the SDK, you have the dlls you can use but not libraries for static linking. If you need static linking, please use the search on the forum and the wiki, there were many topics on that one. You have to build Qt for static linkage from the sources. Sorry, there is no other way for statically linked executables.
Thank you. I'll see what I can do about it. :-)
goetz last edited by
Be aware of the licensing implications, when linking statically to Qt!
Could you please tell me about them? I'm using my programs for the university to create physics simulations!!! I'm not gonna sell them!!
goetz last edited by
Have a look at the tag search, please:
The base line (I'm not a lawyer!) is, that you most probably have to GPL your code if you do static linking (except in case you use commercial license, of course).