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?
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?
You need buid qt library in static mode
a life without programming is like an empty bottle![]()
And how exactly wound one do this? I'm rather new at mass programming.Originally Posted by zlatko
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)
Awesome. Just re-ran configure with the -static flag and it looks like it's going good.
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!
Shouldn't it be "CONFIG += static" (without "-")?
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!
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?
It won't work for the old ones, but anyway you might find these interesting:Originally Posted by bpetty
http://blogs.qtdeveloper.net/archive...ries-on-linux/
http://blogs.qtdeveloper.net/archive...ions-on-linux/
bpetty (1st September 2006)
Bookmarks