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 += openglDEPENDPATH += ../../libsrc
INCLUDEPATH += ../../libsrc
DEPENDPATH += ../../fft
INCLUDEPATH += ../../fftTARGET = BlochSim
TEMPLATE = appCONFIG += warn_off
CONFIG += staticSOURCES += main.cpp
mainwindow.cpp
glwidget.cpp
systemsim.cpp
../NoiseGenerator/Noise.cpp
../../libsrc/param_obj.cpp
../../libsrc/Exception_sam_base.cpp
openglobjects.cpp
blochsim.cpp
../../fft/fft.cpp
optionswidget.cppHEADERS += mainwindow.h
glwidget.h
systemsim.h
../NoiseGenerator/Noise.h
../../libsrc/param_obj.h
../../libsrc/Exception_sam_base.cpp
openglobjects.h
blochsim.h
../../fft/fft.h
optionswidget.hunix:LIBS += -lrt
unix:LIBS += -lm
unix:LIBS += -lpthread
unix:LIBS += -lgsl
unix:LIBS += -lgslcblaswin32:DEPENDPATH += ../../libsrc/gsl/gsl-win-1.8
win32:DEPENDPATH += ../../libsrc/gsl/gsl-win-1.8/lib
win32:INCLUDEPATH += ../../libsrc/gsl/gsl-win-1.8/includewin32: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 :-)
-
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!
Any ideas?
-
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???
-
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. :-)
-
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!!
-
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).