Jump to content

  • Log In with Google      Sign In   
  • Create Account


Compiling a Desktop Application?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
21 replies to this topic

#1 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 23 August 2012 - 02:24 PM

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

Sponsor:

#2 Nypyren   Crossbones+   -  Reputation: 3418

Like
5Likes
Like

Posted 23 August 2012 - 02:37 PM

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.

#3 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 23 August 2012 - 02:55 PM

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

#4 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 23 August 2012 - 03:29 PM

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

~Saint Squireen

#5 Bacterius   Crossbones+   -  Reputation: 7029

Like
4Likes
Like

Posted 23 August 2012 - 03:52 PM

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.

"The best comment is a deleted comment."


#6 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 23 August 2012 - 08:09 PM

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

~Saint Squireen

#7 Servant of the Lord   Crossbones+   -  Reputation: 14970

Like
8Likes
Like

Posted 23 August 2012 - 09:27 PM

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:
Posted Image

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:
Posted Image

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:

Posted Image

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)".

Posted Image

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.

Edited by Servant of the Lord, 23 August 2012 - 09:30 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#8 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 24 August 2012 - 12:50 PM

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

#9 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 28 August 2012 - 05:16 PM

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

#10 Servant of the Lord   Crossbones+   -  Reputation: 14970

Like
1Likes
Like

Posted 28 August 2012 - 05:33 PM

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

Posted Image

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#11 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 28 August 2012 - 05:50 PM

Yes. Follow me through this. I open up QT, go to create a new project, under Choose a Template:, go down to Other Project, then slide the scrollbar in the box next to that down to Plain C++ Project. Thats what I made my project in.

~Saint Squireen

#12 Servant of the Lord   Crossbones+   -  Reputation: 14970

Like
1Likes
Like

Posted 28 August 2012 - 06:15 PM

Alright, well, the DLLs are there on your computer somewhere (Probably "C:\Qt\<your Qt API version>\lib\"). I can find them for you, but their exact location depends on several things like where you installed Qt.

[Edit:] I'll try harder to explain their location tomorrow when I have time.

Edited by Servant of the Lord, 28 August 2012 - 07:08 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#13 BitMaster   Crossbones+   -  Reputation: 3024

Like
1Likes
Like

Posted 29 August 2012 - 02:56 AM

An alternative would be to add -static-libgcc and -static-libstdc++ to the compiler parameters (not sure where exactly to do that in QtCreator).

Edit: Actually it might not be. If he actively links to Qt it is probably precompiled using the dynamic runtime. While it would be possible to recompile them with the static runtime that's not something you should ask a beginner to try.

#14 Servant of the Lord   Crossbones+   -  Reputation: 14970

Like
1Likes
Like

Posted 29 August 2012 - 10:06 AM

Alright, let's try this: Do you know where your "Computer" folder is? If it's not on your desktop, it's available from your start menu:
 
Finding the C:/ drive


Now, there are multiple different locations where you can find the Qt DLLs, depending on what versions you have installed and where you installed them, and with what package you installed them (bundled with QtCreator or not). I have at least three different installs of Qt on my system (don't ask why Posted Image).

For me, I can find mine here: C:\Qt\<qt version>\bin
And here (different install): C:\QtSDK\Desktop\Qt\<qt version>\mingw\bin <-- This is probably your install (my mistake with the earlier suggested path).

If you know how to do a search on Windows, you can also search for "QtCore4.dll" and the other DLLs. I don't recommend this though, because there are multiple copies of QtCore4.dll on your computer, and not all of them are the right one (they aren't all binary compatible with your executable).

This might seem really confusing, but once you get used to it, you'll handle this kind of thing with ease. The problem is I don't know what your knowledge level is, so I'm having to half teach you how to use windows while half-explaining how to use DLLs, while fully explaining where to find the Qt-specific DLLs. Part of any confusion is trying to learn multiple things at once, and part of it is from the people explaining it (me) doing a poor job by being half-blind not knowing your skill level and not visually seeing your computer.

I'm going to walk you through the second possible path I mentioned above. When you are following the paths, and you can't find it exactly, but there is something similar, try that (the DLL names don't change, but the folder names might change slightly).

 
Possible path:
Step 1

Step 2

Step 3

Step 4

Step 5

Step 6

Step 7


 

Once you find the DLLs mentioned, which are the Qt API dlls, you need two more DLLs (the GCC C++ standard language DLLs among other stuff). These are in a different location. Once you find the Qt ones, then I'll explain where the GCC ones are, which are easier to find.

If the Qt DLLs still can't be found, just let me know, and instead what we'll is we'll figure out what version of Qt you are running, and I'll just upload the DLLs somewhere for you to download.

Edited by Servant of the Lord, 29 August 2012 - 10:49 AM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#15 brx   Members   -  Reputation: 626

Like
2Likes
Like

Posted 29 August 2012 - 10:19 AM

If you can't find the Qt DLLs following the excellent description by Servant of the Lord, another tip from me:
- Open up your project in QtCreator
- go to "Projects" (toolbutton in the left pane)
- select "Build Settings" (should be selected by default).
- Now in the "General" category the first entry is "Qt version". Click on "manage" right next to it.
- It should show you the path to the Qt version used by the QtCreator. The "qmake" Location shows you the path of the qmake.exe file which is located in the same folder as the Qt DLLs. Now use the windows explorer to navigate to it and copy the DLLs following SoL's description.

#16 Saint Squireen   Members   -  Reputation: 181

Like
1Likes
Like

Posted 29 August 2012 - 04:41 PM

Hey I found them!! I have all four of them now! Whats the next step?:D

~Saint Squireen

#17 Servant of the Lord   Crossbones+   -  Reputation: 14970

Like
1Likes
Like

Posted 29 August 2012 - 09:14 PM

Congrats! That was located at C:\QtSDK\Desktop\Qt\<qt version>\mingw\bin

Now we need to go to C:\QtSDK\mingw\bin

The DLLs you want are:
  • libgcc_s_dw2-1.dll
  • libstdc++-6.dll
  • mingwm10.dll
Probably. I forget which ones are actually required, but grabbing all three won't hurt. Copy and Paste them into your game's folder.

You should have:

Your stuff:
  • your-game.exe (whatever you name it is fine, as long as it ends in .exe (if you have extensions visible))
  • Your game's data files (images, sounds, etc... These don't have to be in the same folder as your game, but your game needs to know where to find them)
MinGW/GCC and C++ stuff:
  • libgcc_s_dw2-1.dll (the names matter, keep them as-is)
  • libstdc++-6.dll
  • mingwm10.dll
Qt stuff: (if your game was built without debugging information)
  • QtGui4.dll
  • QtCore4.dll
Qt stuff: (if your game was built with debugging information)
  • QtGuid4.dll
  • QtCored4.dll
All the DLLs need to be in the same folder with your game. Then run your game, and if you get a message like ""The program can't start because <some DLL file> is missing from your computer", post the message, and we'll help you find the DLL.

If no message pops up, your game probably has all the right stuff, however it's possible it still might crash or close silently during startup if it can't find your own resource files, depending on how you do your own game's error handling.

Edited by Servant of the Lord, 29 August 2012 - 09:15 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#18 Saint Squireen   Members   -  Reputation: 181

Like
0Likes
Like

Posted 31 August 2012 - 01:52 PM

one sec.....

~Saint Squireen

#19 Saint Squireen   Members   -  Reputation: 181

Like
1Likes
Like

Posted 31 August 2012 - 01:58 PM

I can't believe it!!!!!!! It works now!!!! Yeeeeaaaahhhhhh! Thanks soo much man! So this will work for all of my applications?

~Saint Squireen

#20 Servant of the Lord   Crossbones+   -  Reputation: 14970

Like
0Likes
Like

Posted 31 August 2012 - 02:48 PM

Awesomeness! I'm glad it worked. Posted Image

It depends on what your applications use.
For C++ compiled by MinGW, you'll need the MinGW libraries. (MinGW is your compiler)

For Qt, you'll also need the Qt libraries. (Qt is the API you are using. QtCreator is the IDE you are using (the program you write your code in))
For other APIs, you'll need those APIs' libraries.

Some libraries statically link (meaning the library code is mixed into your executable itself), and some dynamically link (meaning the library code is in the DLLs - Dynamically Linked Library). Anything you dynamically link to, the DLL you are linking against must be able to be found by the executable. This means they must be either: A) In the same directory as the .exe or B) somewhere in the user's PATH environment (a special set of file paths handled by the operating system - paths can be added or removed by installers or by users themselves, and the OS already has some paths built-in).

So: Whatever libraries you use, you need to make sure the library code can be found by your program.

Qt is actually a collection of libraries (I think 5? Plus additional add-on libraries - this is why there are 20 uniquely named dlls in the folder where you found QtCore4.dll), and whichever parts of the library you link against in your program, those are the parts you need. You are only linking against two parts of the library: The Qt Core (QtCore4.dll = Qt Core library, for Qt version 4.x), and the Qt GUI. There are also other parts, like Qt Networking that you aren't currently using or linking against, and so don't need to add.

As mentioned earlier, with Qt, each DLL has a version compiled for Debugging, and a version compiled for Release (meaning there are over 40 DLLs in total in that folder). This is the 'd' in QtCored4.dll. You only need one or the other, depending on which one your program linked against - Since I didn't know which one you linked against, I just had you include both versions to be 100% sure your program would work.

For comparison, my own project uses 16 DLLs: 2 from Qt, 4 from SFML, 2 other libraries required by SFML, 2 from Boost, 1 from Lua, 1 from MinGW, and 4 more small ones to play videos. I'm sure something like World of Warcraft probably has close to a hundred. I see 70 DLLs required by Dungeon Defenders for PC Posted Image (it uses the Unreal Engine, and most of the DLLs are from that). Sometimes a DLL is really small and other times they can be quire large.

Because of my confusion about what's required by MinGW, of your 7 DLLs, you actually only need about 3 of them.
I would guess you probably only need:
  • libstdc++-6.dll
  • QtGuid4.dll
  • QtCored4.dll

You could delete the others from the folder where your executable is, and see if the executable still runs properly, and if it doesn't, add them back one by one until it does run fine. Or, you could use a tool like Dependency Walker which tells you what DLLs your program needs.

Edited by Servant of the Lord, 31 August 2012 - 02:50 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS