PDA

View Full Version : Static Compile [Qt4]



PieaholicX
15th March 2006, 00:30
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?

zlatko
15th March 2006, 08:33
You need buid qt library in static mode

PieaholicX
15th March 2006, 14:37
You need buid qt library in static mode
And how exactly wound one do this? I'm rather new at mass programming.

ksqt
15th March 2006, 14:49
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...

PieaholicX
16th March 2006, 02:59
Awesome. Just re-ran configure with the -static flag and it looks like it's going good.

bpetty
29th August 2006, 18:11
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!

jacek
29th August 2006, 19:45
Shouldn't it be "CONFIG += static" (without "-")?

jpn
29th August 2006, 20:16
QtCentreWiki: Building static applications (http://wiki.qtcentre.org/index.php?title=Building_static_applications)

bpetty
30th August 2006, 17:16
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!

bpetty
31st August 2006, 22:19
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?

jacek
31st August 2006, 22:26
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/archives/2006/02/10/distributing-qt-based-binaries-on-linux/
http://blogs.qtdeveloper.net/archives/2006/05/09/deploying-qt-applications-on-linux/

bpetty
1st September 2006, 17:18
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.