Results 1 to 12 of 12

Thread: Static Compile [Qt4]

  1. #1
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Static Compile [Qt4]

    Okay, I've read it in the FAQ and such, but I'm still not quite sure. How do I compile my Qt programs so that they are statically linked with the Qt libraries?

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    You need buid qt library in static mode
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Static Compile [Qt4]

    Quote Originally Posted by zlatko
    You need buid qt library in static mode
    And how exactly wound one do this? I'm rather new at mass programming.

  4. #4
    Join Date
    Mar 2006
    Posts
    58
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    I actually think I may be able to answer this....
    Download the Qt source (not the one with MinGW exe)....
    Unpack the source....
    Then "configure -static"......
    And after that you will need to make (possibly mingw32-make) or nmake(vc++)......

    My question in my thread is about using the jpeg libraries "statically"...........haven't figured it out yet...

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

    PieaholicX (16th March 2006)

  6. #5
    Join Date
    Mar 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Static Compile [Qt4]

    Awesome. Just re-ran configure with the -static flag and it looks like it's going good.

  7. #6
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    I have had a little trouble getting this to work.

    I can build the static libraries just fine... but my I am still linking against the dynamic libraries. I tried adding this to my .pro file:

    CONFIG += -static

    ...But that didn't do anything.
    To create my libaries I did:
    ./configure -static
    make sub-src

    Then I copied all of the .a libs to my /usr/local/TrollTech/Qt/libs dir.
    Maybe I shouldn't have done that.. I don't know. Anyways... if anyone has any tips, I'd appreciate them.

    Thanks!

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    Shouldn't it be "CONFIG += static" (without "-")?

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Static Compile [Qt4]

    J-P Nurmi

  10. #9
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    Ok, I uninstalled my Qt build... and built everything with the static and release flags.

    As expected, after I did a "make install", I found my static libraries in the lib directory. To my surprise I also saw shared release libraries in the same dir... which is good because I would like to have both.

    The down side is that when I add the "CONFIG += staticlib" or "CONFIG += static" lines in my .pro file... it still builds a shared version!

    I am stumped. If anyone has any ideas... I'd appreciate them.

    Thanx!

  11. #10
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    I finally got it to work. It appears that there is an issue with Qt 4.1 when it comes to compiling with static libraries. If there are shared libraries in the same directory as the static libs... it will always link with the shared libs. At least that is the conclusion I came to trying to get this bastard to link correctly. I tried passing "-static" in the Makefile which should have worked... but I recieved a MOC error about that argument. Adding the "CONFIG += static" in my .pro file did not have any effect. DQT_NO_DEBUG also had no effect... because the shared libraries where debug libraries. I also noticed that when I was setup for shared libraries it sets a few things in the Makefile that resemble that type of linking. When I built the static version those items where missing... which is a good thing. It didn't seem to matter however since it still linked with the shared libs anyways.

    So, sorry for the rant... but if you ever have any problems like I had... you might try the method above. I hope that it is easier to switch between static and shared builds in future releases.

    I also wonder how difficult it would be to create a purely statically linked application under Qt. I am going to pass this thing in binary form to bunch of different linux systems... some old, some new, some Redhat, some Suse... etc. I don't think the shared objects I am linking against will be there. Am I suppose to include these Shared Objects in commercial software?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    Quote Originally Posted by bpetty
    I am going to pass this thing in binary form to bunch of different linux systems... some old, some new, some Redhat, some Suse... etc. I don't think the shared objects I am linking against will be there. Am I suppose to include these Shared Objects in commercial software?
    It won't work for the old ones, but anyway you might find these interesting:

    http://blogs.qtdeveloper.net/archive...ries-on-linux/
    http://blogs.qtdeveloper.net/archive...ions-on-linux/

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

    bpetty (1st September 2006)

  14. #12
    Join Date
    Aug 2006
    Posts
    90
    Thanks
    6
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Static Compile [Qt4]

    Thanks for those links Jacek.

    It will be interesting to see how this plays out. The software I am developing is going to be running on Linux, AIX, Sun OS, and HP Unix.... and Windows. While the LSB trick may work under Linux... I am interested to see how it will play out with the other Unix flavors. I'll talk to Troll Tech about it... and ask our Unix Guru here at work. If I find anything interesting I will post it here incase anyone is interested.

Similar Threads

  1. qtgui4.dll error in visual c++ 2005
    By Comptrol in forum Installation and Deployment
    Replies: 33
    Last Post: 19th June 2008, 07:18
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. Access to PostgreSQL DB on a linux server
    By rmagro in forum Qt Programming
    Replies: 28
    Last Post: 13th March 2008, 09:02
  4. Static compile with jpg support
    By ksqt in forum Newbie
    Replies: 18
    Last Post: 11th May 2007, 04:43
  5. static compile in qt4 with VisualStudio2003
    By iGoo in forum Installation and Deployment
    Replies: 1
    Last Post: 21st July 2006, 08: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.