PDA

View Full Version : Release my simple program to other users ?



probine
21st March 2006, 15:18
I am using Mandriva Linux and Qt-4.1.1

I just created this very simple program:
---------------------------------------------------------
# include <QApplication>
# include <QPushButton>

int main(int argc, char* argv[])
{
QApplication application(argc, argv);
QPushButton btn_hello("Hello World");
btn_hello.resize(150, 100);
btn_hello.show();
return application.exec();
}
--------------------------------------------------------

The program works fine. I would like to give this program to my friends, but they don't have the Qt libraries in their Linux computers, or perhaps they have it, but only with Qt-3.x support.

How do I compile this program as static, so I can just pass it to other persons and know that it will work ?

Please post some compilation code if possible.

wysota
21st March 2006, 15:30
Have a look at the FAQ (http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_use_static) .

probine
21st March 2006, 15:39
You mean that I should recompile everything again from source ?

It took me over 3 hours to compile it and install it !!!

wysota
21st March 2006, 15:48
I'm sorry. If you want to statically link your application, you have to have static libraries. An alternative to static linking is to distribute your application with all the required shared libs.

Chicken Blood Machine
21st March 2006, 21:35
You mean that I should recompile everything again from source ?

It took me over 3 hours to compile it and install it !!!

Well then, save yourself some hassle and just bundle it with the shared libs. If you're on UNIX, be sure to provide a small script that sets the LD_LIBRARY_PATH, so that your prog can find them.

alecs1
9th July 2006, 20:33
So how about the dimensions?
While I don't know about LD_LIBRARY_PATH and distributing the libraries on Unix, on Windows I only pasted the 3 libraries in the executable directory, that means more than 5 MB .dll and a 70 kB .exe :). So what would be the method to make the executable a little bigger (to include the parts from the libraries) and to be stand-alone?

aMan
9th July 2006, 23:17
when you compile qt from source statically, then be sure not to compile the examples and the demos. these take very much disk space (maybe 700 MiB). i've commented them out in some files (don't remeber which ones) and then it went much faster..

a very small program, statically linked, was about 5 mb..

regards, aman..

jacek
9th July 2006, 23:26
when you compile qt from source statically, then be sure not to compile the examples and the demos. [...] i've commented them out in some files (don't remeber which ones) and then it went much faster..
Maybe "make sub-src" would be enough?

aMan
9th July 2006, 23:31
pleas explain..
thanks in advance..

regards, aman..

jacek
9th July 2006, 23:42
pleas explain..
As the docs (http://doc.trolltech.com/4.1/deployment-x11.html) say:

Building Qt Statically
To use this approach, you must start by installing a static version of the Qt library:
cd /path/to/Qt
./configure -static -prefix /path/to/Qt <other parameters>
make sub-src
We specify the prefix so that we do not overwrite the existing Qt installation. The example above only builds the Qt libraries, i.e. the examples and Qt Designer will not be built.