Results 1 to 9 of 9

Thread: how to statically compile a program with qt libs?linux platform

  1. #1
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to statically compile a program with qt libs?linux platform

    I learned that I could statically compile qt libs and then statically compile my program.
    I have statically compiled qt libs and I want to statically compile my program.

    for example,if I need

    QtXml,QtCore,QtGui,phonon,

    and I have these libs of *.a files under /opt/qtstatic/lib,
    how do I write my .pro file to statically compile my program?

    also I wrote my program in a dynamic qt environment,do I need to make any change to my source code?

    thx

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to statically compile a program with qt libs?linux platform

    you don't have to do changes in your source code, you only have to to add
    qmake Code:
    1. CONFIG += static
    To copy to clipboard, switch view to plain text mode 
    in your pro file.

  3. #3
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to statically compile a program with qt libs?linux platform

    Quote Originally Posted by Lykurg View Post
    you don't have to do changes in your source code, you only have to to add
    qmake Code:
    1. CONFIG += static
    To copy to clipboard, switch view to plain text mode 
    in your pro file.
    I'm sorry but:
    I tried it but it seems nothing changed,the program still can't be used on a computer without qt.
    Do i need to specify the location of those static libs in .pro file?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to statically compile a program with qt libs?linux platform

    no that's all. Of course you must use the qmake of your static build, that the right libraries get bound. For Linux also have a loot at: [WIKI]Building static applications[/WIKI].

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

    berlinud (25th August 2010)

  6. #5
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to statically compile a program with qt libs?linux platform

    Quote Originally Posted by Lykurg View Post
    no that's all. Of course you must use the qmake of your static build, that the right libraries get bound. For Linux also have a loot at: [WIKI]Building static applications[/WIKI].
    well,following your help,it is OK now,
    I didn't make install_qmake before,I think that is the reason why I failed.

    May I ask you another question?
    After statically build my program,the phonon backend module doesn't work,
    it works when I use dynamic build,
    What should I do to make it work?

    thx again.

  7. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: how to statically compile a program with qt libs?linux platform

    You need to static link all the phonon plugins too of course.
    And all the other plugins you use too (image formats, etc...)

  8. #7
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to statically compile a program with qt libs?linux platform

    Quote Originally Posted by tbscope View Post
    You need to static link all the phonon plugins too of course.
    And all the other plugins you use too (image formats, etc...)
    May I ask How to static link those plugins?
    Do I need to reconfigure qt adding argument
    -phonon-backend?
    or are there any other way?

    thx

  9. #8
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to statically compile a program with qt libs?linux platform

    I found that most of those plugins in my static qt directory has .a files
    but /plugins/phonon_backend is an exception
    there is only a libphonon_gstreamer.so in it,no .a file!

    and then I configured and made again with argument -static -phonon-backend
    but it didn't change anything

    then I look into the shared qt dirctory installed by the .bin file I downloaded from qt's website.
    Look in /qt/plugins/phonon_backend ,there is also no .a file while all the other folders in that directory has both .a and .so files of the same name

    So I am totally confused now
    I have found that static compile can solve my original problem
    !!!but the problem now I think is that
    I statically compile qt,but I can't get a static phonon_backend lib

    what's wrong with my Qt?will a totally reinstall and remake for static solve this problem?
    plz help me.
    best wishes to everyone.
    I hate confusion really.

  10. #9
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to statically compile a program with qt libs?linux platform

    I found the answer in qt's document.

    http://doc.qt.nokia.com/4.7-snapshot/plugins-howto.html

    it say that static program can only link static plugins.
    and qt doesn't provide static phonon_backend plugin,
    so I can't build a static program with phonon backend.

    thank you everyone for your answer.
    best wishes.

Similar Threads

  1. Statically linking QT libs on symbian
    By bullwinkle in forum Newbie
    Replies: 1
    Last Post: 6th February 2010, 10:25
  2. Link all Qt libs statically.
    By psih128 in forum Installation and Deployment
    Replies: 12
    Last Post: 29th December 2008, 20:48
  3. Compile Qt for Mac statically
    By eric in forum Installation and Deployment
    Replies: 4
    Last Post: 19th August 2008, 15:45
  4. Commpiling program with libs
    By Zergi in forum Newbie
    Replies: 1
    Last Post: 18th January 2008, 18:39
  5. Qt 4.1 - compile regular DLL statically
    By Elder Orb in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 09:28

Tags for this Thread

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.