Results 1 to 4 of 4

Thread: Static linking with Qt

  1. #1
    Join Date
    Jan 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post Static linking with Qt

    Qt version: 4.5.1

    I followed the instructions at

    http://doc.trolltech.com/4.5.1/deplo...-qt-statically

    and I built Qt statically.


    Then I compiled statically an application of mine.


    However that page mentions:

    To check that the application really links statically with Qt, run the ldd tool (available on most Unices):

    ldd ./application

    Verify that the Qt libraries are not mentioned in the output.

    My application does not run as stand alone, producing the following:

    Qt Code:
    1. john@ubuntu810-64:~/Desktop/download$ ./optics
    2. ./optics: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory
    To copy to clipboard, switch view to plain text mode 


    and the aforementioned "ldd ./application" produces:

    Qt Code:
    1. john@ubuntu810-64:~/Desktop/download$ ldd ./optics
    2. linux-vdso.so.1 => (0x00007fff6e5fe000)
    3. libQtGui.so.4 => not found
    4. libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00007f5e66015000)
    5. libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007f5e65d91000)
    6. libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007f5e65b4b000)
    7. libSM.so.6 => /usr/lib/libSM.so.6 (0x00007f5e65942000)
    8. libICE.so.6 => /usr/lib/libICE.so.6 (0x00007f5e65727000)
    9. libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007f5e6551d000)
    10. libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00007f5e652eb000)
    11. libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f5e650d9000)
    12. libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f5e64dd1000)
    13. libQtNetwork.so.4 => not found
    14. libQtCore.so.4 => not found
    15. libz.so.1 => /usr/lib/libz.so.1 (0x00007f5e64bb9000)
    16. libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007f5e649b4000)
    17. librt.so.1 => /lib/librt.so.1 (0x00007f5e647ab000)
    18. libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0x00007f5e644e6000)
    19. libdl.so.2 => /lib/libdl.so.2 (0x00007f5e642e2000)
    20. libpthread.so.0 => /lib/libpthread.so.0 (0x00007f5e640c6000)
    21. libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f5e63db9000)
    22. libm.so.6 => /lib/libm.so.6 (0x00007f5e63b34000)
    23. libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f5e6391c000)
    24. libc.so.6 => /lib/libc.so.6 (0x00007f5e635aa000)
    25. libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007f5e63380000)
    26. libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f5e6317e000)
    27. libxcb-xlib.so.0 => /usr/lib/libxcb-xlib.so.0 (0x00007f5e62f7c000)
    28. libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f5e62d60000)
    29. /lib64/ld-linux-x86-64.so.2 (0x00007f5e6623c000)
    30. libpcre.so.3 => /lib/libpcre.so.3 (0x00007f5e62b37000)
    31. libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f5e62932000)
    32. john@ubuntu810-64:~/Desktop/download$
    To copy to clipboard, switch view to plain text mode 

    If I understand correctly, the "not found" libraries are the only ones not statically linked in the executable.

    Any ideas on how to achieve this?


    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Static linking with Qt

    No. All the libraries mentioned here are linked dynamically. You didn't compile your application statically, at least not against any of the libraries mentioned in the output you posted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Ade Malsasa Akbar (3rd June 2013)

  4. #3
    Join Date
    Jan 2009
    Posts
    29
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Static linking with Qt

    Can we explicitly specify at make or qmake the static library files we want to link?

  5. #4
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Static linking with Qt

    Quote Originally Posted by prykHetQuo View Post
    Can we explicitly specify at make or qmake the static library files we want to link?
    In Linux, if you just say -lfoo, the linker will look for libfoo.so first, if not found, then it looks for libfoo.a. From your ldd outputs, you have dynamic Qt libraries in the path...

    You can force it to link to static one using -Wl,-Bstatic as

    LIBS += -Wl,-Bstatic -lfoo

    Then it will pick up static first. Try to play with your pro file, you should be able to figure it out...

  6. The following user says thank you to lni for this useful post:

    Ade Malsasa Akbar (3rd June 2013)

Similar Threads

  1. problem on static linking in Linux.
    By anupamgee in forum Installation and Deployment
    Replies: 1
    Last Post: 29th May 2009, 14:45
  2. Static linking of Qt programs
    By divya balachandran in forum Qt Programming
    Replies: 0
    Last Post: 15th September 2008, 13:10
  3. Replies: 16
    Last Post: 23rd May 2008, 11:12
  4. Qt 4.3 static linking on Windows
    By john_crichton in forum Installation and Deployment
    Replies: 2
    Last Post: 13th May 2008, 07:57
  5. Replies: 4
    Last Post: 20th February 2006, 10:11

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.