creatron
18th May 2014, 22:32
I have read many solutions, an have tried many.. but they all end up with dependancies in the executable in Linux. I did mange to do this however in Windows and got it working and could check the exe with depend.exe
1. I build a static QT build with the following
./configure -prefix /usr/local/Trolltech/Qt-4.8.5_static -static -qt3support -plugin-sql-mysql -release -nomake demos -nomake examples -nomake tools -qt-zlib -qt-libpng -qt-libmng -qt-libjpeg -qt-libtiff -no-webkit
2. I then ran gmake, (wait a few hous) and then gmake install as root, and as expected I have a new build at /usr/local/Troltech/Qt4.8.5_static
3. I then add the following to the pro file
CONFIG += release
unix {
MOC_DIR = .moc
OBJECTS_DIR = .obj
DEFINES += _LINUX_
CONFIG(release){
TARGET = release/comms_spy # debug_binary
} else {
TARGET = debug/comms_spy # release_binary
}
CONFIG += static
}
}
RESOURCES += images.qrc
static {
CONFIG += static
DEFINES += STATIC
message("Static build.")
LFLAGS = -static-libgcc
}
If I build this now in QTCreator (Added the new QT version and changed it in the kit), it uses the correct path for the static build, for example an extraction of the build show
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -D_QT_ -DDLMS -DFLIR -DGSSII -DIDS816 -DMEA -DMETRO -DMIT -DMP3 -DONCE -DPTP -DSECURITY -DXNCORP -D_LINUX_ -DSTATIC -D_LINUX_ -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Trolltech/Qt-4.8.5_static/mkspecs/linux-g++ -I. -I/usr/local/Trolltech /Qt-4.8.5_static/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5_static/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5_static/include -I.moc -I. -o .obj/comms_spy.o 2
comms_spy.cpp)
etc
4. The file size increase from 500K to approx 16Meg, and the message "Static build." is displayed during the build phase,
This look promising but if I use LDD , or a script file downloaded I get this ( the Qt dependencies are gone BUT )
gerrie@linux-bk94:~/worksheet/creatron/comms_spy/release> ldd comms_spy
linux-vdso.so.1 (0x00007fff8dfb7000)
libgobject-2.0.so.0 => /usr/lib64/libgobject-2.0.so.0 (0x00007fc966fda000)
libSM.so.6 => /usr/lib64/libSM.so.6 (0x00007fc966dd2000)
libICE.so.6 => /usr/lib64/libICE.so.6 (0x00007fc966bb6000)
libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00007fc9669ac000)
libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007fc96676f000)
libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007fc9664dd000)
libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007fc9662cb000)
libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fc965f8d000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fc965d89000)
libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007fc965b87000)
libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007fc965884000)
librt.so.1 => /lib64/librt.so.1 (0x00007fc96567c000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc96545e000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc965156000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc964e53000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc964c3c000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc96488d000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc96722b000)
libffi.so.4 => /usr/lib64/libffi.so.4 (0x00007fc964685000)
libuuid.so.1 => /usr/lib64/libuuid.so.1 (0x00007fc964480000)
libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007fc964256000)
libz.so.1 => /lib64/libz.so.1 (0x00007fc964040000)
libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007fc963e03000)
libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fc963be4000)
libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007fc96397e000)
libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fc96377a000)
gerrie@linux-bk94:~/worksheet/creatron/comms_spy/release> ./depends.sh comms_spy
-------------------------------------------------------------------------------------------------------------
ldd-nonnative: find all dependencies of a (potentially) non-native binary comms_spy
-------------------------------------------------------------------------------------------------------------
comms_spy
libgobject-2.0.so.0
libSM.so.6
libICE.so.6
libXrender.so.1
libfontconfig.so.1
libfreetype.so.6
libXext.so.6
libX11.so.6
libdl.so.2
libgthread-2.0.so.0
libglib-2.0.so.0
librt.so.1
libpthread.so.0
libstdc++.so.6
libm.so.6
libgcc_s.so.1
libc.so.6
ld-linux-x86-64.so.2
I this now a 'static' build that is suppose to run an 'any' linux box ??
1. I build a static QT build with the following
./configure -prefix /usr/local/Trolltech/Qt-4.8.5_static -static -qt3support -plugin-sql-mysql -release -nomake demos -nomake examples -nomake tools -qt-zlib -qt-libpng -qt-libmng -qt-libjpeg -qt-libtiff -no-webkit
2. I then ran gmake, (wait a few hous) and then gmake install as root, and as expected I have a new build at /usr/local/Troltech/Qt4.8.5_static
3. I then add the following to the pro file
CONFIG += release
unix {
MOC_DIR = .moc
OBJECTS_DIR = .obj
DEFINES += _LINUX_
CONFIG(release){
TARGET = release/comms_spy # debug_binary
} else {
TARGET = debug/comms_spy # release_binary
}
CONFIG += static
}
}
RESOURCES += images.qrc
static {
CONFIG += static
DEFINES += STATIC
message("Static build.")
LFLAGS = -static-libgcc
}
If I build this now in QTCreator (Added the new QT version and changed it in the kit), it uses the correct path for the static build, for example an extraction of the build show
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -D_QT_ -DDLMS -DFLIR -DGSSII -DIDS816 -DMEA -DMETRO -DMIT -DMP3 -DONCE -DPTP -DSECURITY -DXNCORP -D_LINUX_ -DSTATIC -D_LINUX_ -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/local/Trolltech/Qt-4.8.5_static/mkspecs/linux-g++ -I. -I/usr/local/Trolltech /Qt-4.8.5_static/include/QtCore -I/usr/local/Trolltech/Qt-4.8.5_static/include/QtGui -I/usr/local/Trolltech/Qt-4.8.5_static/include -I.moc -I. -o .obj/comms_spy.o 2
comms_spy.cpp)
etc
4. The file size increase from 500K to approx 16Meg, and the message "Static build." is displayed during the build phase,
This look promising but if I use LDD , or a script file downloaded I get this ( the Qt dependencies are gone BUT )
gerrie@linux-bk94:~/worksheet/creatron/comms_spy/release> ldd comms_spy
linux-vdso.so.1 (0x00007fff8dfb7000)
libgobject-2.0.so.0 => /usr/lib64/libgobject-2.0.so.0 (0x00007fc966fda000)
libSM.so.6 => /usr/lib64/libSM.so.6 (0x00007fc966dd2000)
libICE.so.6 => /usr/lib64/libICE.so.6 (0x00007fc966bb6000)
libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00007fc9669ac000)
libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007fc96676f000)
libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007fc9664dd000)
libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007fc9662cb000)
libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fc965f8d000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fc965d89000)
libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007fc965b87000)
libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007fc965884000)
librt.so.1 => /lib64/librt.so.1 (0x00007fc96567c000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc96545e000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc965156000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc964e53000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc964c3c000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc96488d000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc96722b000)
libffi.so.4 => /usr/lib64/libffi.so.4 (0x00007fc964685000)
libuuid.so.1 => /usr/lib64/libuuid.so.1 (0x00007fc964480000)
libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007fc964256000)
libz.so.1 => /lib64/libz.so.1 (0x00007fc964040000)
libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007fc963e03000)
libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fc963be4000)
libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007fc96397e000)
libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fc96377a000)
gerrie@linux-bk94:~/worksheet/creatron/comms_spy/release> ./depends.sh comms_spy
-------------------------------------------------------------------------------------------------------------
ldd-nonnative: find all dependencies of a (potentially) non-native binary comms_spy
-------------------------------------------------------------------------------------------------------------
comms_spy
libgobject-2.0.so.0
libSM.so.6
libICE.so.6
libXrender.so.1
libfontconfig.so.1
libfreetype.so.6
libXext.so.6
libX11.so.6
libdl.so.2
libgthread-2.0.so.0
libglib-2.0.so.0
librt.so.1
libpthread.so.0
libstdc++.so.6
libm.so.6
libgcc_s.so.1
libc.so.6
ld-linux-x86-64.so.2
I this now a 'static' build that is suppose to run an 'any' linux box ??