PDA

View Full Version : problem with running exe files.



zupermustafa
15th November 2012, 06:48
hey guys,

I am using QT Creator 2.6.0 with QT 5.0.0 Beta 2 on Vista. (downloaded it yesterday 500MBs)

Pre knowledge: I decided to learn C++ last week. I downloaded QT and wrote some simple but handy programs.

My Problem: My programs work fine when I run them from QT CREATOR. However when I try to run my application as exe file, it asks for DLL files. It asks crazy amount of DLL files (up to 40 MBs) and even after adding them all into that folder it doesnt run. It doesnt even give errors.

What I want: I want to be able to run my program outside of QT CREATOR. And give it to my friends without forcing them to install any other thing. (like .netframework 4.xxx like visual C++ 2010 does)

What I know and dont want:
1. I spent 3 days googling the problem checking over 100 articals. I know I need to make it static or dynamic.
2. http://doc.qt.digia.com/4.5/deployment-windows.html
cd C:\path\to\Qt
configure -static <any other options you need>
in this example I cant make "configure" work. I searched the entire computer but there is no such file. I still tried the code in several locations searching for a miracle but it keeps saying "configure is not recognized as internal or external command......" so I am stuck in that phase about static building.
3. I tried the dynamic build. I created a new "Qt Guil Application", builded it in RELEASE mode. Even tho it didnt have any single code in it yet, still it asks amazing number of DLL files yet still does not run afterwards as i explained above. In my youth I used to code with visual basic and I still have them. they are around 40-200 KBs with some cool games inside. The DLL files needed for QT application is around 20 MBs which is insane. There must be an other way.

I searched the entire forum and i couldnt find the answer I am looking for.
tnx in advance.
Musti.

Lesiok
15th November 2012, 10:48
Take this magic tool (http://www.dependencywalker.com/) and look what DLL You need.
P.S.
And read how to deploy Qt application (http://doc.qt.digia.com/latest/deployment.html).

zupermustafa
15th November 2012, 17:14
Take this magic tool (http://www.dependencywalker.com/) and look what DLL You need.
P.S.
And read how to deploy Qt application (http://doc.qt.digia.com/latest/deployment.html).


Lesiok, Please read the question again. You are giving links to sites I linked above myself. I know what DLLs the program needs and I already read (linked) the article about deploying. Total amount of DLLs I added is around 80 MBs and the "empty" product is still not working.

I am waiting answers from people who are actually able to read the question. Please dont waste my time with stupid and irrelevant answers.

Tnx in advance.
Musti.


--Addition. Or just say that QT is not able to create standalone(static) or light weight (dynamic) programs like Visual C++ or Visual Basic so I can stop wasting my time for a program that incapable.

ChrisW67
16th November 2012, 00:15
You are quite able to create lightweight programs using Qt dynamic libraries but you have to understand that you are comparing apples and oranges. The 'lightweight' programs you get from Visual C++ are dependent on collections of DLLs, C++ runtimes, or .Net runtime environments that are assumed present on any Windows machine and are often, therefore, not present in the application bundle. The 200k-400k VB games you so fondly recall were dependent on a several megabytes of Visual Basic runtime and supporting files installed into Windows directories, i.e. the supporting files were 4-5 times larger than the program executable (Since XP you can assume these are already present). Qt does not have the luxury of assuming its DLLs and plugins are present and you must ship them with your application.

First be sure you have built and are deploying a release mode application, which you claim to have done. The debug versions of the application and libraries (e.g. QtCore5d.dll) are much larger and unnecessary. Do not deploy DLLs you are not using, the basic hello world GUI requires QtCore, QtGui, and QtWidgets but not QtWebkit. Second, you must deploy any imageformat and similar plugins that are required by your program. These do not show in Dependency Walker unless you run the program in the profiler, and even then it loads all available plugins, not just the ones your require. Skipping this second step is most likely why your applications starts but silently fails. Deploying plugins has been repeatedly covered in this forum.

You can also use UPX or something similar to compress the DLLs further although this is generally unnecessary if you use any sort of installer because these generally compress their payload for transmission.

You can also build a static Qt application, by building a static Qt, building your application with that, and living with the technical and licensing restrictions that may impose. You need the Qt source code and its dependencies in order to build a static Qt. I don't know if the source is included in the 500MB binary distribution you have, but if there is no "configure" or "configure.exe" anywhere on your machine then I guess that answers the question.

Both deployment options are shown on the page you list and its parent page, but you should be reading the deployment page for the Qt 5 version you have in case anything of substance has changed. It is installed in Assistant and available here (http://qt-project.org/doc/qt-5.0/deployment.html).

If you really cannot handle deploying a few files to support your executable then I suggest you use Microsoft's tools, stick exclusively to .Net 3.0, abandon support for XP which has no .Net by default, and abandon any cross-platform ability.

zupermustafa
18th November 2012, 07:54
All this time 2 answers and both of them are wrong.

I contacted some old friends to get the answer which is actually very simple. IT IS NOT POSSIBLE TO WRITE LIGHT PROGRAMS WITH QT

The guy above mentioned some rubbish about needing libraries. Maybe true but that wasnt my question. I am able to write a 50KB program with visual basic or visual C++ and send it to all my friends. They can all use it. Vista, 7, XP, CentOS, Knuppix, etc...

So, to see the ignorance of this community I am kindy asking again making the question as simple as possible. I tested the question on my 3 year old nephew and he understood the question so I am hoping you guys will understand it this time.

1. Is it possible to write a simple program that would be below 100KBs? I hope you guys know what KB means.
2. If yes, write a 2+2 program and tell me all the steps you need to do to create the final product.
3. Note that the program must be cross-platform. I should be able to use it on all linux and windows operating systems.

I am asking not the get an answer but to see the capacity of this community. I started learning C++ 2 weeks ago on my spare times and I see I already know more than guys above. Thats simply sad.

Hoping to get an sensible answer this time.
Musti.

amleto
18th November 2012, 14:46
http://i1133.photobucket.com/albums/m585/amleto/tumblr_mbg8avSm0Y1qbs6bho1_500.jpg


Has anyone really been far even as decided to use even go want to do look more like?

wysota
18th November 2012, 16:42
All this time 2 answers and both of them are wrong.
Lol...


I contacted some old friends to get the answer which is actually very simple. IT IS NOT POSSIBLE TO WRITE LIGHT PROGRAMS WITH QT
Lol...


#include <QtGui>

int main(int argc, char **argv) {
QApplication app(argc, argv);
QLabel l("Hello world");
l.show();
return app.exec();
}

$ ls -sh prog
8,0K prog

For me it is pretty much lightweight (main.o is only 3KB, the rest is GCC startup code) :)


The guy above mentioned some rubbish about needing libraries. Maybe true but that wasnt my question. I am able to write a 50KB program with visual basic or visual C++ and send it to all my friends. They can all use it. Vista, 7, XP, CentOS, Knuppix, etc...
Please send your Visual Basic program to me too, I'd like to use it. You can attach it as a zip archive to your post so that we can all download it. The program can be as simple as displaying a red text "I know how to deploy my apps" in a window. If you want a more demanding task, create a Visual Basic app displaying QtCentre.org website in a window. Additional points for fitting it inside 10kB (my Qt app doing this is 12kB, with main.o being 3kB again and the rest, the linking and GCC initialization code and it took me about 2 minutes to write it, build it and test it).


1. Is it possible to write a simple program that would be below 100KBs? I hope you guys know what KB means.
Yes and there is no reason to treat people as if they were stupid asking them whether they knew what "KB" meant, that's plain rude.


2. If yes, write a 2+2 program and tell me all the steps you need to do to create the final product.
See above. It's not 2+2 but rather a simple "hello world" app (so it does more than your "2+2 program"). Steps required to build and run on any LSB Linux are qmake -project, qmake, make, run the executable. You can also transfer the sole executable and run it on any LSB 3.2+ Linux (LSB stands for "Linux Standard Base", most Linux distros nowadays are LSB compliant) with the same architecture.


3. Note that the program must be cross-platform. I should be able to use it on all linux and windows operating systems.
Be my guest, let's make the code Public Domain -- take it, do whatever you want with it. There is nothing platform specific in this code, you can build it on any Qt-supported platform.


I started learning C++ 2 weeks ago
I will be very blunt here. I think it is more than rude to spend 2 weeks of spare time on learning something and claim to have eaten all the answers on the subject, come to any community devoted (even remotely) to that language and behave like you are behaving. I can understand your irritation (regardless if it is right or not) but that doesn't justify your behaviour. Especially that your problems have nothing to do with the language.

And I can easily prove you are wrong with your and your friends' "knowledge". Create a simple 2+2 app using Visual Studio 2010 (possibly even 2008 or even 2005 in case of Win2k) and then run it on vanilla Windows 2000 or Windows XP (by vanilla I mean that nothing has been added to the system after it has been installed, like when launching the system for the first time). When you finally stop scratching your head as why it didn't work as you had expected it to, come back here and write "I'm sorry for misdjudging this community and possibly offending people who had tried to help me". Then spend some more time on learning the tools you like to use. Perhaps some page on MSDN on deploying applications in Windows environment will prove helpful (as I understand it is Windows platform that you're battling with right now, apps are usually easier to deploy in U**x environment than in Windows).


on my spare times and I see I already know more than guys above. Thats simply sad.

Unfortunately it is something else that is sad... And again I can prove you wrong. We know how to run our apps, you don't, so how come can you know more than we do?

As homework, do this -- launch your beautiful 50KB Visual Basic (or Visual C++) game and check how much memory it occupies in total (I'm not talking about what the Windows task manager displays, that's rubbish). It will probably occupy much much more than several megabytes of RAM. Now ponder, if the code for your app is only 50kB, what is contained in the rest of the memory used by the process? Where does the remaining code come from? Another hint: the clever program you are using for checking the amount of memory occupied should tell you how much memory is used by code, how much by data and how much by stack. Let's not care about stack right now and focus solely on code and data.

zupermustafa
18th November 2012, 23:42
God, I read lots of LOLs but I still dont have an answer for my very simple question.

I am not a programmer so ofcourse you guys know how to run your programs and I dont. Thats why I came to this forum. I am interested in programming only as a hobby. When I said I know more it is related to the understanding of the question and as far as I can see, still no answer.

@wysota I am not interested how KBs it is in memory or how much it is in the compiler. I am interested in how much it is when I send it to my friend. FOR GODS SAKE how hard can it be to understand this? You guys have serious issues and that explains the general problem with QT in the market.

I own a company and there are times I need my IT department do some simple things both on web or servers. When they say it is impossible, I usually ask around.

When I wrote to this forum was the second day of my QT adventure which ends now as I see this community is hopeless. I asked a simple question. What must I do, step by step, everything in detail to transport my simple program (can be hello world). However all the answers were not related to my problem. Instead of trying to understand the problem, you guys are in the heaven of competence.

When you will actually start working in the market, you will understand what I mean.

For now, I am going to buy an icecream to my 3 year old nephew in that weather. He earned it.

Added after 17 minutes:

btw, I have been following some other places for the same question. Now I got 2 more comfirmation that it is not possible with QT to write a standalone working exe file with less than 50KBs.

Ok, lets say that general idea is true and size does not matter. Since you guys claim to know everything and believe you can explain anything, I will give you a second chance to redeem your rudness. Please only answer if you actually want to give an answer this time. Others who want to laugh can laugh at their ignorance anytime alone.

QUESTION: Write hello program and LIST all the steps necessary to create a final product that can be delivered to someone else. Step by step.

Added after 9 minutes:

:( I was wasting my time with someone who got 3 thanks in 30 thousand posts. So you are right, I wont judge the whole community because of acts of some ignorant kid.

amleto
19th November 2012, 00:22
Well we know you can't read, but can you say hypocrite? Hy-po-crite. Don't let the door hit you... *wave*

john_god
19th November 2012, 01:25
You should ask your nephew if he knows the difference between being rude and being polite, being arrogant and being humble.


QUESTION: Write hello program and LIST all the steps necessary to create a final product that can be delivered to someone else. Step by step.

You already have been told the necessary steps, and you already should know since you have a background with visual basic but in a last effort to help you:

1) put your exe file with the required dll's in the same directory
2) zip it and send it to your friends
3) An alternative to number 2) is to use some software like innosetup, install creator, installshield, or whatever and create a nice setup.exe file.

That's all there is to it, Qt is just a toolkit, and deploying in windows follows the same rules that other toolkit do.

If your program does not work outside QtCreator, with the steps I gave you, you have errors that are not possible to identify with the information that you have provided.

Also please note, is Qt not QT ( QuickTime) and Wysota got almost 4k thanks, not 3 :)

wysota
19th November 2012, 01:46
I am not a programmer so ofcourse you guys know how to run your programs and I dont.
So don't be rude to people who are willing to share their knowledge with you.


@wysota I am not interested how KBs it is in memory or how much it is in the compiler. I am interested in how much it is when I send it to my friend.

Without proper understanding of how computer programs in modern systems work, you'll be always banging your head against problems like this.


You guys have serious issues and that explains the general problem with QT in the market.
I'm reaching a certain point in my patience but I'll repeat this once more -- problems you are having are nothing Qt related. Qt is just another C++ library. If you used any other C/C++ library, you'd be in exactly the same situation. If you want to use some library that is not bundled with systems you wish to support then sorry --- you have to deploy that library on the target system along with any dependencies it might have. That's a rule of thumb for any C, C++, Python, Perl, Visual Basic, Ruby, Java, <name your favourite programming language here> program. Have a look at any large application installed on your machine -- see how many DLLs it carries within its install dir.


I own a company
Yes, unfortunately that explains a lot. Company owners often think they can be offensive to their employees. But we are not your employees so please behave.


When I wrote to this forum was the second day of my QT adventure which ends now
Great! Finally. Go back to your Visual Basic and stick with it. Unfortunately that's hardly cross-platform and you won't be able to do much more with it than write simple 50kB games but that's not my problem. Your world will be safe.


I asked a simple question. What must I do, step by step, everything in detail to transport my simple program (can be hello world).
And you have been given detailed answers. You just didn't accept them but that is your problem not ours.


Instead of trying to understand the problem
We understand your problem. The answer to your problem is: you need to find dependencies of your program by using Dependency Walker (Windows) or ldd (Linux) and ship them along your application binary. We will not tell you what those dependencies are exactly because they might vary. For sure this will be the compiler runtime (MSVC/MinGW) and Qt libraries your app uses (probably at least QtCore and QtGui) and also any other library you use in your program.


When you will actually start working in the market, you will understand what I mean.
You really think we're a band of amateurs here, right? Most of us have worked as professional programmers for years.


btw, I have been following some other places for the same question. Now I got 2 more comfirmation that it is not possible with QT to write a standalone working exe file with less than 50KBs.
It is if you care to spend time to do it. However again, you will not write a standalone working exe file with less than 50KB in any other language, including Visual Basic that needs the whole Visual Basic runtime to execute (so your "working exe" will not be "standalone"). Is it really that hard to understand?


I will give you a second chance to redeem your rudness
I have not yet began to be rude.


QUESTION: Write hello program and LIST all the steps necessary to create a final product that can be delivered to someone else. Step by step.
That's not a question. And if we treat it as a question, I have already answered it in this post.


:( I was wasting my time with someone who got 3 thanks in 30 thousand posts.
Learn to read. I gave 3 thanks, not I was given 3 thanks.

chong_kimkeang
19th November 2012, 02:58
I used to have similar problem in Qt Creator, but I don't know if it can work with your app or not. If you want exe file to run independently, first create a folder for putting your exe file then copy the folder named qml in the directory that you create your app to put in the folder that you put the exe file. :)
So the folder will contain one exe file and qml folder.

ChrisW67
19th November 2012, 03:00
All this time 2 answers and both of them are wrong.
Really?

I contacted some old friends to get the answer which is actually very simple. IT IS NOT POSSIBLE TO WRITE LIGHT PROGRAMS WITH QT

The guy above mentioned some rubbish about needing libraries. Maybe true but that wasnt my question. I am able to write a 50KB program with visual basic or visual C++ and send it to all my friends. They can all use it. Vista, 7, XP, CentOS, Knuppix, etc...

Explain to me how you make a VB program run on a CentOS or Knuppix [sic] system and I won't consider this a load of unmitigated rubbish.

As I explained above, you are comparing apples and oranges. Your 50kB Visual Basic executable only works because all of the libraries that it cannot possibly function without are already deployed with any modern Windows. If you include all the dependent libraries for either a modern VB or Qt program in your size-of-application assessment you'll find they are comparable. If you assess size purely on the size of the main executable then, once again, they are comparable. If you compare the size of one option's bare executable against another option's total deployed size then you are not comparing likes.


So, to see the ignorance of this community I am kindy asking again making the question as simple as possible. I tested the question on my 3 year old nephew and he understood the question so I am hoping you guys will understand it this time.

Simple questions, simple answers.


1. Is it possible to write a simple program that would be below 100KBs? I hope you guys know what KB means.

Yes you can, and yes I know what kB means.


2. If yes, write a 2+2 program and tell me all the steps you need to do to create the final product.

Sure, I'll even make gratuitous use of Qt even though it is not required for this example:

Y:\tt>type main.cpp
#include <QApplication>
#include <QLabel>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QLabel label(QString::number(2+2));
label.show();
return app.exec();
}

Y:\tt>qmake -project
Y:\tt>qmake CONFIG+=release
Y:\tt>mingw32-make
mingw32-make -f Makefile.Release
...
Y:\tt>dir release
Volume in drive Y is VBOX_tmp
Volume Serial Number is 0000-0822

Directory of Y:\tt\release

19/11/2012 11:35 AM 1,497 main.o
19/11/2012 11:36 AM 59,904 tt.exe
2 File(s) 61,401 bytes
0 Dir(s) 76,253,519,872 bytes free

Size of program < 100kB (even smaller if built on Linux, probably a little smaller if built with Microsoft C++)

Deployment to another machine involves ensuring all the dependencies are present on the target machine. This is required for deployment of any program, written with any tools, on any platform. If your VB.Net application use .Net 4.5 then you need to deploy the ~50MB .Net 4.5 run time to Windows 7 machines, if it uses Qt 5 then you need to deploy (some) Qt5 libraries, if it uses Java then you need to deploy a Java runtime and classes. See the pattern?



Y:\tt>mkdir deploy
Y:\tt>copy release\tt.exe deploy
1 file(s) copied.
Y:\tt>copy c:\QtSDK\Desktop\Qt\4.8.0\mingw\bin\QtCore4.dll deploy
1 file(s) copied.
Y:\tt>copy c:\QtSDK\Desktop\Qt\4.8.0\mingw\bin\QtGui4.dll deploy
1 file(s) copied.
Y:\tt>copy c:\QtSDK\Desktop\Qt\4.8.0\mingw\bin\mingwm10.dll deploy
1 file(s) copied.
Y:\tt>copy c:\QtSDK\Desktop\Qt\4.8.0\mingw\bin\libgcc_s_dw2-1.dll deploy
1 file(s) copied.
Y:\tt>dir deploy
Volume in drive Y is VBOX_tmp
Volume Serial Number is 0000-0822

Directory of Y:\tt\deploy

02/04/2012 02:00 PM 43,008 libgcc_s_dw2-1.dll
02/04/2012 02:00 PM 10,135,040 QtGui4.dll
19/11/2012 11:36 AM 59,904 tt.exe
02/04/2012 02:00 PM 11,362 mingwm10.dll
02/04/2012 02:01 PM 2,843,136 QtCore4.dll
5 File(s) 13,092,450 bytes
0 Dir(s) 76,240,388,096 bytes free

Y:\tt>"c:\Program Files\7-Zip\7z.exe" a -r deploy.zip deploy
...
Y:\tt>dir deploy.zip
Volume in drive Y is VBOX_tmp
Volume Serial Number is 0000-0822

Directory of Y:\tt

19/11/2012 11:45 AM 5,345,534 deploy.zip
1 File(s) 5,345,534 bytes
0 Dir(s) 76,235,026,432 bytes free

Total deployment bundle size about 5 MB.

Of course, you don't need Qt for a 2+2 program, and if you don't use Qt then you don't need to deploy Qt.

By your definition of lightweight, i.e. the size of a complete installer for the program, then any non-trivial Qt GUI program for deployment to an out-of-the-box Windows will not be 'lightweight' but that total size does not grow with lines-of-code. The less trivial the program the less of an overhead. After the first time you deploy this to a machine the executable can be replaced alone: a total of less than 100 kB.



3. Note that the program must be cross-platform. I should be able to use it on all linux and windows operating systems.

Well, that certainly counts out your Visual Basic comparison. You can compile and run the program above on Windows XP, Vista, 7, 8, Linux, Mac OS X, and possibly Android and embedded systems. It may run on Windows 2000 also.

If you don't want to deploy anything other than your program executable to any Windows system then I have already given you your option.

Gokulnathvc
21st November 2012, 07:55
Try with static building:

1. Install QtSDK (2009.05)

2. Open your mkspecswin32-g++qmake.conf file (located in C:\Qt\2009.05\qt\mkspecs\win32-g++\qmake.conf) in an editor like notepad.

3. Find the line that starts with "QMAKE_LFLAGS = -enable-stdcall-fixup..." and ddd the phrase "-static" (without quotes) after the "=" sign and before the "-enable..." phrase, so it looks like:
QMAKE_LFLAGS = -static -enable-stdcall...

4. Save and close this file.

5. Set your environment variables. Right-click Computer >> Properties >> Advanced System Settings >> Click the "Environment Variables..." button.

6. Under "User variables," make sure QTDIR is set to your Qt path (C:\Qt\2009.05\qt). Make sure QMAKESPEC is set to win32-g++.

7. Under "System variables," edit the one called "Path." Add a semicolon ( ; ) to the end, and add the following:
C:\Qt\2009.05\mingw\lib;C:\Qt\2009.05\mingw\bin;C: \Qt\2009.05\qt\bin

8. When finished, relog or reboot.

9. Open a command prompt.

10. Change to your Qt directory by entering: cd C:\Qt\2009.05\qt

11. Enter the following: configure -static -no-phonon -no-phonon-backend -release -no-exceptions

12. When it asks which edition you want to use, enter "o" for open source.

13. When it asks you to accept the terms of the license, enter "y" for yes. This will take around maybe 10 minutes to complete.

14. When that finishes, enter the following: mingw32-make sub-src (or) nmake sub-src

15. Go out to dinner, this will take a while (took between 1-2 hours for me).

16. When this finishes, open your project in the Qt Creator.

17. Double-click the project (.pro) file to open it in edit mode.

18. Add the following line: CONFIG += static

19. qmake Hello.pro
nmake release (or) mingw32-make release

20. Navigate to your release directory and voila! Your standalone executable should be there.

zupermustafa
30th November 2012, 08:35
Thank you Gokulathvc for giving exactly what I asked for. While others got lost in my attitude, you actually listed an excellent answer.

To all others. My problem was version 5.0 which had some bugs preventing the process. All this time I provoked you all to see this problem but you all got lost in your angers. Solution was simple. "I was using the wrong version".

Thanks Gokul... for actually giving a proper answer. I am writing this so others who have the same problem can benefit from it.

Added after 31 minutes:

I checked the lines and there are some minor differences with what I did .

open QT command prompt it has to be QT command prompt
C:\Qt\2010.05\qt>configure -platform win32-g++ -static -release -no-exceptions (this takes around 10 minutes)
C:\Qt\2010.05\qt>mingw32-make sub-src (takes around 40 minutes)
You do those two sections individually. It takes damn long time.

After that in Name.pro section you type this in the end
CONFIG += static
You also have to do that in your program or it doesnt work. I havent really tasted it for major programs yet but it fixes my minor problem so far.

wysota
30th November 2012, 10:01
My problem was version 5.0 which had some bugs preventing the process.

Let me see... your program was running when started from QtCreator and wasn't running when started manually and a conclusion to this was that Qt5 was at fault even though the program was working fine when executed from Creator?