How to make an standalone .exe of simple Qt console application
Hello I am using QtMinGW 5.6 Creator (Community) open source edition on windows 7
I would like to know how to build my application so it can run standalone in an exe.
The guides ive looked up did not work
Your post is not very clear about how you deployed your .exe. Usually when deploying a Qt app you must also deploy all related dlls used by the .exe. This is normal for Windows with any kind of application and particularly Qt.
Try running the windeployqt.exe file which you will probably find in the Qt bin folder where you installed Qt.
See this doc for more details... Qt for Windows - Deployment
I don't develop on Windows using QtMinGW I use MSVC so I am not sure about QtMinW specifics but I hope this information will give you a hint.
I have looked at that documentation. I am not too familair with turning my program into .exe's at all so i dont know how i "deployed it".
running windployqt.exe just automatically opens and closes quickly
in that windows deployment tutorial i have tried t o type the commands in windows cmd prompt but none of them work as it says "not recognized as an internal or external command..."
OK well, I usually do it using a batch file run from QtCreator. If you do it by hand it should be done like this.
in a command window enter the following
<path to windeployqt>windeployqt.exe --verbose=3 --dir <path to your deployment directory> <path to your Qt app .exe >yourQtApp.exe
I recommend you prepare a directory to put the result of the deployment in because you will get a ton of folders and files in there depending on what Qt modules you used in your app.
The usual rules about spaces in paths apply here so use "" if you have spaces in the paths.
The --verbose=3 will give you a ton of output so you can see what was done.
You should be good to go after that.
Thank you for the quick reply, i have done that command.
Does this directory contain all the shared dlls i need and i just add my release .exe into this folder or any other .exe i want to use?
As far as I recall your Qt app.exe should also be copied to the deployment folder you specified with the --dir option.
If it was not copied then yes, copy it to the same folder.
You will see all the dlls and other files and subfolders with dlls that your app needs in the deployment folder you specified.
Your app should run from that folder and it should find the dlls it needs.
nevermind i fixed the error.
So do i jsut need to run this everytime i want to deploy an .exe and it will grab every single library i need ? or will i sometimes need to add my own .dlls
You really only need to run that deployment tool at first deployment or when you change the Qt libraries or the version you use but there is no harm in running it every time you build... it takes up time to copy stuff.
And yes, I think you need to add any libraries that Qt does not know about.
Thank you for your help!
Also do you happen to know if they have an .exe to make a static exe without the .dlls or do i have to do it some other way
You must use a static build of Qt to build a static application. That means you must build a static Qt yourself. I think you must have the commercial license to be able to do that legally but I am not an expert on that kind of thing.
Someone else might be able to help with that question so I would mark this post as solved and post a new question about that kind of thing