Results 1 to 2 of 2

Thread: Static build have dependencies Qt 4.8.5 (Linux Opensuse 13.1)

  1. #1
    Join Date
    Aug 2008
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Static build have dependencies Qt 4.8.5 (Linux Opensuse 13.1)

    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
    Qt Code:
    1. ./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
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. CONFIG += release
    2. unix {
    3. MOC_DIR = .moc
    4. OBJECTS_DIR = .obj
    5. DEFINES += _LINUX_
    6. CONFIG(release){
    7. TARGET = release/comms_spy # debug_binary
    8. } else {
    9. TARGET = debug/comms_spy # release_binary
    10. }
    11. CONFIG += static
    12. }
    13. }
    14. RESOURCES += images.qrc
    15. static {
    16. CONFIG += static
    17. DEFINES += STATIC
    18. message("Static build.")
    19. LFLAGS = -static-libgcc
    20. }
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. 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
    2. comms_spy.cpp)
    3. etc
    To copy to clipboard, switch view to plain text mode 
    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 )
    Qt Code:
    1. gerrie@linux-bk94:~/worksheet/creatron/comms_spy/release> ldd comms_spy
    2. linux-vdso.so.1 (0x00007fff8dfb7000)
    3. libgobject-2.0.so.0 => /usr/lib64/libgobject-2.0.so.0 (0x00007fc966fda000)
    4. libSM.so.6 => /usr/lib64/libSM.so.6 (0x00007fc966dd2000)
    5. libICE.so.6 => /usr/lib64/libICE.so.6 (0x00007fc966bb6000)
    6. libXrender.so.1 => /usr/lib64/libXrender.so.1 (0x00007fc9669ac000)
    7. libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007fc96676f000)
    8. libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007fc9664dd000)
    9. libXext.so.6 => /usr/lib64/libXext.so.6 (0x00007fc9662cb000)
    10. libX11.so.6 => /usr/lib64/libX11.so.6 (0x00007fc965f8d000)
    11. libdl.so.2 => /lib64/libdl.so.2 (0x00007fc965d89000)
    12. libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007fc965b87000)
    13. libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007fc965884000)
    14. librt.so.1 => /lib64/librt.so.1 (0x00007fc96567c000)
    15. libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc96545e000)
    16. libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc965156000)
    17. libm.so.6 => /lib64/libm.so.6 (0x00007fc964e53000)
    18. libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc964c3c000)
    19. libc.so.6 => /lib64/libc.so.6 (0x00007fc96488d000)
    20. /lib64/ld-linux-x86-64.so.2 (0x00007fc96722b000)
    21. libffi.so.4 => /usr/lib64/libffi.so.4 (0x00007fc964685000)
    22. libuuid.so.1 => /usr/lib64/libuuid.so.1 (0x00007fc964480000)
    23. libexpat.so.1 => /usr/lib64/libexpat.so.1 (0x00007fc964256000)
    24. libz.so.1 => /lib64/libz.so.1 (0x00007fc964040000)
    25. libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007fc963e03000)
    26. libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x00007fc963be4000)
    27. libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007fc96397e000)
    28. libXau.so.6 => /usr/lib64/libXau.so.6 (0x00007fc96377a000)
    29. gerrie@linux-bk94:~/worksheet/creatron/comms_spy/release> ./depends.sh comms_spy
    30. -------------------------------------------------------------------------------------------------------------
    31. ldd-nonnative: find all dependencies of a (potentially) non-native binary comms_spy
    32. -------------------------------------------------------------------------------------------------------------
    33. comms_spy
    34. libgobject-2.0.so.0
    35. libSM.so.6
    36. libICE.so.6
    37. libXrender.so.1
    38. libfontconfig.so.1
    39. libfreetype.so.6
    40. libXext.so.6
    41. libX11.so.6
    42. libdl.so.2
    43. libgthread-2.0.so.0
    44. libglib-2.0.so.0
    45. librt.so.1
    46. libpthread.so.0
    47. libstdc++.so.6
    48. libm.so.6
    49. libgcc_s.so.1
    50. libc.so.6
    51. ld-linux-x86-64.so.2
    To copy to clipboard, switch view to plain text mode 

    I this now a 'static' build that is suppose to run an 'any' linux box ??

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Static build have dependencies Qt 4.8.5 (Linux Opensuse 13.1)

    Yes, just same thing happens on Windows. You have statically linked your program and the Qt libraries (which are not in the ldd output). The Qt libraries are still dynamically linked to their external dependencies (just like the Windows exe will still require kernel32.dll and friends). You may be able to to compile some of those libraries to have static equivalents, if they do not already, and contrive that the static libraries are found before the dynamic libraries at Qt library build time. IIRC there may even be an internal copy of libz in Qt you could turn on.

Similar Threads

  1. Building an application using static QT libraries on Linux openSuse 10.2
    By mmeerten in forum Installation and Deployment
    Replies: 1
    Last Post: 1st July 2010, 21:35
  2. Replies: 17
    Last Post: 6th May 2010, 19:54
  3. Build without any dependencies
    By Dato0011 in forum Qt Tools
    Replies: 5
    Last Post: 22nd December 2009, 15:21
  4. Linux dependencies
    By LMZ in forum Qt Programming
    Replies: 6
    Last Post: 21st May 2007, 07:54
  5. QMAKE: Specifying Build Dependencies
    By JohnSuykerbuyk in forum Qt Programming
    Replies: 1
    Last Post: 5th May 2006, 09:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.