Why is my basic program 178 megs in size
-
i am using Qt_SDK_Win_offline_v1_1_2_en.exe in windows xp service pack 3. i compiled my program which is a form with a push button on it. i ran the program but it said that i needed a dll. i copied all the needed dlls over to the dir and the 4 dlls that i needed totals 178 megs in size which is an outrage. how can i run my basic windows program without the needed 178 megs in dlls?
-
mainwindow.h
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();private:
Ui::MainWindow *ui;
};#endif // MAINWINDOW_H@
main.cpp
@#include <QtGui/QApplication>
#include "mainwindow.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();return a.exec();
}@
mainwindow.cpp
@#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}MainWindow::~MainWindow()
{
delete ui;
}@EDIT : @tags added by Eddy. Please use the button with <> on it on top of this editor.
-
I think you tried to "deploy" debug version. You need to copy release version of QtCore + QtGUI, the size of these two being 11.8 Mb with mingw and 9,98 MB with VC2008, but for VC2008 you need VC redistributable or to integrate merge modules in your installer
-
You don't need to compile Qt libraries. They already exist on your hdd through QtSDK and are located in .../QtSDK/Desktop/Qt/4.7.3/mingw/bin directory. Note that are named without d (not QtCored). Also you need to compile your application in release mode. If you are using QtCreator, goto in Project tab, and choose from "Edit build configuration" your mingw release configuration. If you use qmake, qmake.exe yourproject.pro -r -spec win32-g++ "CONFIG+=release"
-
If you use Qt Creator, in the lower left corner there is button with this settings, or just add to your Project.pro file
@CONFIG += release@ -
You can try "static":http://doc.qt.nokia.com/latest/deployment-windows.html compilation as well.
-
[quote author="Rahul Das" date="1311759984"]You can try "static":http://doc.qt.nokia.com/latest/deployment-windows.html compilation as well. [/quote]
Be careful with static compilation. First of all, there are no static libs provided by default so you would have to create them. Second, there are some license issues on that, e.g. AFAIK closed source with LGPL might not use static libs.
-
[quote author="cincirin" date="1311752501"]You don't need to compile Qt libraries. They already exist on your hdd through QtSDK and are located in .../QtSDK/Desktop/Qt/4.7.3/mingw/bin directory. Note that are named without d (not QtCored). Also you need to compile your application in release mode. If you are using QtCreator, goto in Project tab, and choose from "Edit build configuration" your mingw release configuration. If you use qmake, qmake.exe yourproject.pro -r -spec win32-g++ "CONFIG+=release"[/quote]
when i am compiling my program, how not to compile the Qt libraries?
-
If you did not, make sure you have removed all Qt modules you don't need from your project.
From MSVC menu: Qt > Qt project Settings > Qt Modules, tab. (if you have the MSVC addin installed, wihich I strongly recommend for you).What was said before was not about your code compilation it is about the Qt you are using.
Explaining: you have to compile Qt yourself, i.e. put away the one you downloaded and build another Qt for you from src code, using Visual Studio in your case, for static build. This Qt will generate a single .exe that will be self-contained. I never compiled the static version, but just in case you don't know:
-Qt compilation have to be configured correctly as Visual Studio compliant, static build,etc. (search the forum or google it)
-Qt compilation may/will take some time (hours)
-As mentioned above, there might be license restrictions to your software -
the static version seems a bit complicated only to get a smaller program size at compilation and without the dlls i am assuming. When you say self-contained, are you saying that the dlls are inside of the exe file? Also, the possible license restrictions i do not like. I will stay with my downloadable qt version.
Will there be license restrictions if i use the downloadable qt version to compile my program?
I don't think I have the MSVC addin installed because there is no MSVC menu in the qt creator.
-
Started a new topic "here":http://developer.qt.nokia.com/forums/viewthread/8219/ about licensing.
-
[quote author="Rahul Das" date="1311840634"]Started a new topic "here":http://developer.qt.nokia.com/forums/viewthread/8219/ about licensing. [/quote]
There are many such topics already. Please use the search option, and refer to them first.
-
If you are going to use visual studio to generate your code, you can download the msvc addin "here":http://qt.nokia.com/downloads/visual-studio-add-in. Then you will have some menus for Qt inside visual studio. Otherwise (MinGW), forget it :-)