Results 1 to 15 of 15

Thread: Qt application is not compiling with static linking?

  1. #1
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Qt application is not compiling with static linking?

    Hi,

    1. I am developing a GUI based Qt Desktop application. I want to compile this application with static linking so that it will run on any ubuntu system.
    I am http://www.qtcentre.org/wiki/index.p...ic_application link to compile the source with static linking but it is not working for me.

    export PATH="$PATH:/usr/local/Trolltech/Qt-4.7.4/bin" is setting the environment variable but when logout or close the terminal and #echo $PATH, then qmake's path is not in this.

    2. can i install only source package on ubuntu for developement without any other Qt installation and how?

    3. Is there any way to do setting for static linking in Qt creator.

    Please help
    Thanks

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt application is not compiling with static linking?

    Quote Originally Posted by gurmeetsingh View Post
    I want to compile this application with static linking so that it will run on any ubuntu system.
    So why you need static linking? Qt is a part of Ubuntu distribution!
    To deploy app you should use debian packege system with marked required dependency. Then when package is installed calling:
    sudo apt-get install -f
    will install all needed libraries (of Qt).
    In case when package is install from package repository everything should be automatic.

    If you don't know how to make debian package just install qt-libraries manually:
    sudo apt-get install libqt4-dev
    will install most of the Qt libraries.

    You can try install minimal number of packages (depending what kind of features you app is using):
    sudo apt-get install libqt4-gui libqt4-core

  3. #3
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Qt application is not compiling with static linking?

    Thanks Marek for your response.

    I am developing a GUI based application which will install printer driver on ubuntu. It is actually a setup kind of executable as it is required by the client.
    While installing the printer, it will give flexibility to user to choose port, set name of printer etc.
    How i can acheive this?

    Can you provide any step by step guide to create .deb package as it is also required by client and i have not found any useful link reason being newbie?

    Thanks.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt application is not compiling with static linking?

    Quote Originally Posted by gurmeetsingh View Post
    1. I am developing a GUI based Qt Desktop application. I want to compile this application with static linking so that it will run on any ubuntu system. I am http://www.qtcentre.org/wiki/index.p...ic_application link to compile the source with static linking but it is not working for me.

    export PATH="$PATH:/usr/local/Trolltech/Qt-4.7.4/bin" is setting the environment variable but when logout or close the terminal and #echo $PATH, then qmake's path is not in this.
    Environment variables set (and exported) in a shell are available for the life of that shell to any sub-process. This is NOT setting the default system or user path in a persistent way (read https://help.ubuntu.com/community/EnvironmentVariables, a mere Google search away) .

    I assume that /usr/local/Trolltech/Qt-4.7.4 is where you have installed a version of Qt built for static linkage, otherwise these second part of this doesn't seem related to the first. Rather than try to set a system-wide path that includes this copy of Qt (as the default) perhaps you should just tell your copy of Qt Creator about this install of Qt and let it worry about the path. That's done from The Tool menu, Options, Qt4 panel.

    2. can i install only source package on ubuntu for developement without any other Qt installation and how?
    No. To compile from source you need a compiled Qt installation as well as the matching compiler and any other referenced libraries.

    3. Is there any way to do setting for static linking in Qt creator.
    Build a static linkage version of Qt. Tell Qt Creator where to find it (see above). Build your project using that copy of Qt. Profit!

    Can you provide any step by step guide to create .deb package as it is also required by client and i have not found any useful link reason being newbie?
    Ubuntu Packaging Guide. Deployment packaging is not trivial, and every application is different. You will be lucky to find a cut-and-paste solution. From your struggle with the PATH I suspect your level of UNIX system understanding will make building a customer-proof package quite a challenge for you.

  5. The following user says thank you to ChrisW67 for this useful post:

    gurmeetsingh (31st January 2012)

  6. #5
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Qt application is not compiling with static linking?

    Thanks Chris for your valueable reply.

    I am MS VC++ developer on MS WIndows and newbie on ubuntu as well as Qt.

    I assume that /usr/local/Trolltech/Qt-4.7.4 is where you have installed a version of Qt built for static linkage, otherwise these second part of this doesn't seem related to the first. Rather than try to set a system-wide path that includes this copy of Qt (as the default) perhaps you should just tell your copy of Qt Creator about this install of Qt and let it worry about the path. That's done from The Tool menu, Options, Qt4 panel.
    I am unable to set the PATH for my application in Tools, options, Qt4 panel. I can change other parameters like 4.7.4 and Desktop Qt 4.7.3 for gcc etc but Qt in Path is disabled.
    Attached herewith the screen shot for the same.

    one more question please
    I have installed Qt 4.7.4, can i build my application with Qt 4.8.0 source for static linkage?

    Thanks in advance.
    Attached Images Attached Images

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

    Default Re: Qt application is not compiling with static linking?

    Quote Originally Posted by gurmeetsingh View Post
    I am unable to set the PATH for my application in Tools, options, Qt4 panel.
    Please read Chris's post again. He didn't tell you to set PATH for your program in there.

    I can change other parameters like 4.7.4 and Desktop Qt 4.7.3 for gcc etc but Qt in Path is disabled.
    Click on the big "Add" button on the right of the window.

    Before continuing please first think what is the goal you want to achieve by doing the action you are going to do. Right now you are acting like putting a monkey in front of a typewriter hoping it will write an epic story by randomly striking keys.
    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.


  8. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt application is not compiling with static linking?

    "Qt in PATH" is not editable because there is either is, or is not, a qmake in the system PATH and you cannot change that situation from Qt Creator. It is largely irrelevant here because you don't want to use the Qt in the system PATH anyway.

    You can define any number of Qt versions/builds by using, as wysota elegantly pointed out, the Add button and then tell Creator where to find the qmake from that copy of Qt. Once you have a copy of Qt identified to the IDE you can associate that version with your Projects Build Settings (see the left tool bar in Creator). Qt Creator will then use that qmake to build your application, and that qmake will ensure that you use its associated files when building. Since you will be using a statically linked Qt, the resulting executable should have few, if any, external dependencies at run time.

  9. #8
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application is not compiling with static linking?

    Hi Chris,

    I have compiled Qt application with static linking.
    The size of previous applicatio with dynamic linking was 8.7 KB and after compiling with static linking it becomes 13.2 MB. It is just a demo application which displays a label only.
    After compiling with static linking, it is again not running on another ubuntu system.
    can you suggest what may be the problem?

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

    Default Re: Qt application is not compiling with static linking?

    Please run ldd yourapplicationexe and post the result. Do the same on the other system and also post the result.
    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.


  11. #10
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt application is not compiling with static linking?

    ldd <appName>

    Output on my system
    Qt Code:
    1. linux-gate.so.1 => (0x0080c000)
    2. libjpeg.so.62 => /usr/lib/i386-linux-gnu/libjpeg.so.62 (0x002e3000)
    3. libmng.so.1 => /usr/lib/i386-linux-gnu/libmng.so.1 (0x00e5f000)
    4. libtiff.so.4 => /usr/lib/i386-linux-gnu/libtiff.so.4 (0x00110000)
    5. libpng12.so.0 => /lib/i386-linux-gnu/libpng12.so.0 (0x00aec000)
    6. libgobject-2.0.so.0 => /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 (0x00bda000)
    7. libSM.so.6 => /usr/lib/i386-linux-gnu/libSM.so.6 (0x00b1f000)
    8. libICE.so.6 => /usr/lib/i386-linux-gnu/libICE.so.6 (0x00335000)
    9. libXrender.so.1 => /usr/lib/i386-linux-gnu/libXrender.so.1 (0x00173000)
    10. libfontconfig.so.1 => /usr/lib/i386-linux-gnu/libfontconfig.so.1 (0x009b5000)
    11. libfreetype.so.6 => /usr/lib/i386-linux-gnu/libfreetype.so.6 (0x0017e000)
    12. libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0x009eb000)
    13. libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0x0034f000)
    14. libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0x00627000)
    15. libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x0030a000)
    16. libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 (0x00262000)
    17. librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x00f1e000)
    18. libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0x00485000)
    19. libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00d2d000)
    20. libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0x00d5e000)
    21. libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0x0088a000)
    22. libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0x002bc000)
    23. libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x0063c000)
    24. /lib/ld-linux.so.2 (0x00f9c000)
    25. liblcms.so.1 => /usr/lib/i386-linux-gnu/liblcms.so.1 (0x00215000)
    26. libffi.so.6 => /usr/lib/i386-linux-gnu/libffi.so.6 (0x0024e000)
    27. libuuid.so.1 => /lib/i386-linux-gnu/libuuid.so.1 (0x00255000)
    28. libexpat.so.1 => /lib/i386-linux-gnu/libexpat.so.1 (0x008f6000)
    29. libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0x00268000)
    30. libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0x00a52000)
    31. libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0x0025b000)
    32. libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0x00c3f000)
    To copy to clipboard, switch view to plain text mode 

    Output on another system
    Qt Code:
    1. not a dynamic execuatble
    To copy to clipboard, switch view to plain text mode 

    Thanks.

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

    Default Re: Qt application is not compiling with static linking?

    So first of all all these from the first printout are dynamic libraries your app depends on. If you want your program to be trully static, you need static versions of most of these so that you can link static Qt against them.

    Second of all it seems the architecture on the second machine is different than the one on the first.

    What does file <yourapp> show and what does uname -a return on both machines?
    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.


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

    gurmeetsingh (31st January 2012)

  14. #12
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Qt application is not compiling with static linking?

    Hi Wysota,

    Output on my system:
    Qt Code:
    1. file <myApp>:
    2. Demo_: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
    3. uname -a
    4. Linux ravi-desktop 3.0.0-15-generic #26-Ubuntu SMP Fri Jan 20 15:59:53 UTC 2012 i686 i686 i386 GNU/Linux
    To copy to clipboard, switch view to plain text mode 

    Output on Another System:
    Qt Code:
    1. file <myApp>:
    2. Demo_: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
    3. uname -a:
    4. Linux ubuntu 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
    To copy to clipboard, switch view to plain text mode 

    Is the problem due to architecture difference?

    Thanks.
    Last edited by gurmeetsingh; 31st January 2012 at 14:27.

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

    Default Re: Qt application is not compiling with static linking?

    Aparently the other system doesn't have support for running 32bit binaries.
    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.


  16. #14
    Join Date
    Jan 2012
    Location
    India
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink Re: Qt application is not compiling with static linking?

    Thanks Wysota and Chriss for your valuable reply.

    I will test it on system having same configuration as my system.

    If i face problem then i will again irritate you.

    Thanks

  17. #15
    Join Date
    Apr 2012
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt application is not compiling with static linking?

    Hi ChrisW67,

    I wanted to build a Qt application with static link and stumbled upon this post. When i try to include a new PATH to the new (static) qmake, it says Qt version not installed properly" -> How do i rectify this ?

Similar Threads

  1. problem compiling qt application using static external libraries
    By pavan1984 in forum Installation and Deployment
    Replies: 0
    Last Post: 5th October 2010, 12:41
  2. Compiling static application
    By Benjamin in forum Qt for Embedded and Mobile
    Replies: 9
    Last Post: 23rd December 2008, 12:45
  3. Replies: 1
    Last Post: 16th September 2008, 18:29
  4. Static Linking Application for Realease
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2007, 19:12
  5. Replies: 2
    Last Post: 1st August 2007, 16:04

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.