Compiling a Desktop Application?

Started by
20 comments, last by Servant of the Lord 11 years, 7 months ago
Does anybody know how to "Compile" a desktop application? I use "Compile" loosely because I don't know if thats the term I am looking for. Basically all I want to do is be able to have an app on my desktop that I can just click or double click and open it and run my game. P.S.- A plus if I can share the app easily, such as linking it in an email (if its small enough of corse) or file share it.

~Saint Squireen
Advertisement
Depends on if you're using Windows or OSX or something else. "Compile" is generally the correct term to use when converting source code to an executable.

If you're talking about taking your executable, DLLs and assets and dealing with them as a unit, I've heard it called "packaging" and "deployment".

On Windows, you need to compile your code such that it generates an EXE file. After that, the EXE file can be put almost anywhere (including your desktop, but people normally put shortcuts on the windows desktop, not the EXE itself). Any dependencies that the EXE has (such as DLLs or game assets like bitmaps, 3d models, sounds, etc) must be located with it or installed to a search path. Most programs will come in an installer which unpacks everything to C:\Program Files (x86)\YourAppName and sets up any registry keys you might need, but you can often just Zip up all the files and give them to someone else and have them unzip them in their Downloads folder if they want.

On OSX, all I can remember is that there's a folder you have to set up that contains the executable, some configuration metadata files, your assets, etc. Then that folder is more-or-less treated as a unit when you want to share or install it.
I am on windows and the only programs and games that I have written so far are basic coding (only text). No sounds, colors, shapes or any of that awesome stuff. Btw, I am using QT as my coding application (because I am practicing widgets and all that). So do you know how to make an executable for that?

~Saint Squireen
I think the proper term for 'basic coding (only text)' is Command Line Program or Command Line Game.

~Saint Squireen
Clearly if you are using Qt and are under Windows you are already producing executables in some fashion. They should be in your project's bin folder somewhere (make sure your file explorer is not set to "hide known file extensions"). Then you can double-click on the .exe and it should produce a console window and run your program.

Note sometimes the console window immediately closes once your program ends (this doesn't happen while developing because your IDE prevents it from doing that), to prevent this put a system("PAUSE") or a readln() before the final return which will hang the program until you hit a key to exit.

About sharing, make sure you only hand out release builds, because otherwise your program might need extra developer libraries that the person you're sharing the program with probably doesn't have.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

ok thanks:) but one question, what do you mean extra developer libraries?

~Saint Squireen
You say you are using "Qt". Do you mean QtCreator? Are you using C++ with that?

C++ is the programming language you maybe are using.
Qt is a set of libraries (also called an API) for C++ that are also available in other languages.
QtCreator is a C++ code editor (also called an IDE) similar to how Microsoft Word is an "english language editor", that is made for using Qt with C++ in an easier manner.

To answer this, does the program you type code in look like this:
qtcreator.png

If so, in the bottom-left corner, you have three large buttons: A green arrow, a green arrow with a blue bug, and a hammer:
qtcreatorbuttons.png

Compiling is the process of taking the text and turning it into something the computer can run.

Whenever you click any of those three buttons, if your program compiles without errors, you'll generate what's called an "executable". Wherever you told QtCreator to save your project, your executable should be somewhere near there.

Executables using Qt can't run on their own - they need some DLLs (the Qt libraries) to be put in the same folder with the executable to be able to run properly.

The default location your project might have been saved in (if using Windows), is in C:/Users/<username>/ but it depends. Do a search for your project name in Windows Explorer, and it'll probably turn up.

Once you find your project folder, look for a folder called something like "desktop-debug" or "debug" or "release" or something like that. Just look inside every subfolder. What you are looking for is your executable. The file extension is '.exe', but if you can't see any file extensions (Windows has them turned off by default), if you see something that looks like the file highlighted in red:

executable1.png

And if it says "Application" or "Executable" or "Binary" in Windows Explorer's info pane (highlighted in blue), and if it's in a subfolder of your project, it is probably maybe your game. Right click on the excutable, select "Send To -> Desktop (create shortcut)".

executable2.png

You need the two DLLs highlighted in green (the 2nd to last screenshot) as well. Those are probably located at "C:\Qt\<your Qt API version>\lib\", and the ones you want are called:

QtGui4.dll
QtGuid4.dll
QtCore4.dll
QtCored4.dll

The .dll part of the name might not be visible. It's also possible that the '4' would be replaced with a '5'.

The reason why there are two versions of each DLL (one with a 'd' before the 4, and one without) is because the ones with the 'd' are for if your executable was built using debugging enabled... which it probably is. Just incase, to simplify things, copy all four of them into the folder where your executable is. (Note: You are COPYING don't cut or move. Copy). The DLLs must be copied in the exact same folder as your executable (not your executable's shortcut, but the original executable itself).

Maybe your program will run when you double-click the executable. If a error message pops up, tell us exactly what it says.

It's all kinda confusing if this is your first introduction to all this stuff (but fairly simple once you get the hang of it). If you're having trouble with it, post here with what part you don't understand.
Thanks I'll be sure to try this. I'm not capable of reaching my computer yet but I will soon. I'll post back either asking for help or saying thank you but either way, I'll post back. Thanks again:)

~Saint Squireen
For some reason i dont have any dll's or anything like that. Also i get this image?text box saying "The program can't start because mingwm10.dll is missing from your computer. Try reinstalling the program to fix this problem." What do i do now?

~Saint Squireen
Do you write your code into a program that looks like this?

qtcreator.png

This topic is closed to new replies.

Advertisement