Tuesday, February 9th 2010, 10:19am UTC

You are not logged in.

  • Login
  • Register

aleshus

Beginner

Posts: 4

Location: Prague, Czech Republic

1

Wednesday, February 13th 2008, 9:18am

static compiling

Hi to all.. Please can anybody tell me how I can staticly link my application on Windows?? On linux I haven´t any problems, because there is everythig dynamicaly linked. But on windows peoples usualy work with static linked probrams.

I found this page:

http://qtnode.net/wiki?title=Building_static

there is wrote that finally size of program will be over five megabytes. But I found this too:

https://128.101.142.230/people/faculty/s…e/qt/index.html

This program was written in Qt too, but its size is only about 600-700kB. So my question is how I can make it. I am using Qt 4.3.3 and Eclipse with Eclipse Qt integration. From it I can´t run programs in other way, than from Qt command prompt.

Thanks for help.
umi tu nekdo cesky?
  • Go to the top of the page

2

Wednesday, February 13th 2008, 10:01am

RE: static compiling

why not use dll?
Nicolas
  • Go to the top of the page

aleshus

Beginner

Posts: 4

Location: Prague, Czech Republic

3

Wednesday, February 13th 2008, 10:07am

RE: static compiling

Quoted

Originally posted by Nicolas SOUCHON
why not use dll?


because their size is more than 10MB and my chief wants only one exe file.
umi tu nekdo cesky?
  • Go to the top of the page

macabre13

Trainee

Posts: 127

Location: Poland/ Wroclaw

Occupation: sw developer

4

Wednesday, February 13th 2008, 10:23am

I belive that in qt configuration you can direct, that qt should be linked in static/dynamic way. Or check the .pro file for override this settings.
- ebm - noise - industrial -
I always could be wrong.
Lets share knowledge!
  • Go to the top of the page

aleshus

Beginner

Posts: 4

Location: Prague, Czech Republic

5

Wednesday, February 13th 2008, 12:20pm

Quoted

Originally posted by macabre13
I belive that in qt configuration you can direct, that qt should be linked in static/dynamic way. Or check the .pro file for override this settings.


and can somebody tell me what I should to write as options?? I tried to write alone but it always crashed with errors.
umi tu nekdo cesky?
  • Go to the top of the page

macabre13

Trainee

Posts: 127

Location: Poland/ Wroclaw

Occupation: sw developer

6

Wednesday, February 13th 2008, 12:42pm

Windows:

configure /?

gives you an option in confiure to

Quoted


* -shared ............ Create and use shared Qt libraries.
-static ............ Create and use static Qt libraries.

note: The defaults (*) are usually acceptable


I belive that the same option goes in linux. For override the .pro file Nicolas should know the answer ;) Or check the doc.trolltech.com
- ebm - noise - industrial -
I always could be wrong.
Lets share knowledge!
  • Go to the top of the page

7

Wednesday, February 13th 2008, 12:43pm

try CONFIG += staticlib
Nicolas
  • Go to the top of the page

8

Wednesday, February 13th 2008, 12:52pm

as an observation

for Qt, static could be expansive

two applications runing at the same time cause libraries to be loaded two times

the same for your application, but no problem if it is single instance and the only Qt application to run
Nicolas
  • Go to the top of the page

aleshus

Beginner

Posts: 4

Location: Prague, Czech Republic

9

Wednesday, February 13th 2008, 1:07pm

Quoted

Originally posted by Nicolas SOUCHON
as an observation

for Qt, static could be expansive

two applications runing at the same time cause libraries to be loaded two times

the same for your application, but no problem if it is single instance and the only Qt application to run


this is no problem for me, because program will run only once. Problem is only size of finally program, but I don't know how much, because I recompiling Qt for static linking yet. After that I'll try it.

But as I wrote above, I found program written in Qt staticly linked with size about 600kB! So I think that must be able to create that small file with static linking. In my opinion MinGW can reduce unnecessary stafs from program.
umi tu nekdo cesky?
  • Go to the top of the page

rensdenobel

Beginner

Posts: 2

Location: The Netherlands / Argentina

Occupation: Technical Lead

10

Thursday, February 28th 2008, 4:21pm

Follow this guide to compile your QT application in static mode :

http://qtnode.net/wiki?title=Building_static

As you will see, you'll have to recompile the QT library itself before you can compile your QT application and use statically linked libraries.
This will take about 10-20 minutes.

You'll find yourself a huge output executable after compiling your application in static mode.

To strip this executable from unused stuff, start the QT command prompt, change directory to where your output executable is located and type 'strip <executablename>' , e.g. 'strip test.exe'.

This dramatically lowers the filesize.
With a default Eclipse / QT configuration and a very basic GUI application with one form with a few buttons and no fancy code, your statically linked output file will be around 60 MBs before stripping and around 8 MBs after.

If you decide to compress it with the UPX executable compressor, the size will be just over 2 MBs.

I'm curious if people have had other results or have more tips to reduce the filesize.
  • Go to the top of the page

11

Thursday, February 28th 2008, 11:27pm

are you sure you didn't compile debug version

if so, on Linux, you can add in the .pro file
CONFIG += separate_debug_info

as an example, on Linux, using shared objects,
for about 40000 lines (.h and .cpp files)
stripped libxxxx.so is ~2.5 MBytes
debug infos libxxxx.so.debug is ~26 MBytes
Nicolas

This post has been edited 1 times, last edit by "Nicolas SOUCHON" (Feb 28th 2008, 11:28pm)

  • Go to the top of the page

Rate this thread