• Advertisement
Sign in to follow this  

Compiling a Desktop Application?

This topic is 1969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:
[hr]
[rollup="Finding the C:/ drive"]
startmenu20120829103014.png
computer20120829102653.png
[/rollup]

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 laugh.png).

For me, I can find mine here: C:\Qt\<qt version>\bin
And here (different install): C:\QtSDK\Desktop\Qt\<qt version>\mingw\bin [color=#ff0000]<-- This is probably your install ([size=2]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).

[hr]
Possible path:
[rollup="Step 1"]
operatingsystemc2012082.png[/rollup]
[rollup="Step 2"]qtsdk20120829102705.png[/rollup]
[rollup="Step 3"]desktop20120829102711.png[/rollup]
[rollup="Step 4"]qt20120829102716.png[/rollup]
[rollup="Step 5"]44461260.png[/rollup]
[rollup="Step 6"]mingw20120829102724.png[/rollup]
[rollup="Step 7"]The highlighted files are (some of) the ones you need. COPY do not cut or delete. Copy them to the same folder with your game executable.bin20120829102750.png[/rollup]

[hr]

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ([size=2]whatever you name it is fine, as long as it ends in .exe (if you have extensions visible))
    • Your game's data files ([size=2]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

Share this post


Link to post
Share on other sites
Awesomeness! I'm glad it worked. biggrin.png

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 happy.png (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

Share this post


Link to post
Share on other sites
Wow thanks for all this knoledge! I'll definitely be checking back here if I ever have trouble again hahaha Also as just a tip, how hard was it to line SFML up with QT and have it run properly? I tried to do it before but it didn't work out at all':/ but as you probably know already, I have no idea what I'm doing when I'm trying to connect stuff together hahahaha

Share this post


Link to post
Share on other sites
It wasn't too hard to get them working together - the hard part that they both have different programming styles and paradigms that don't line up too well with each other, so I find myself constantly having to switch between two distinct styles of architecture in the same project - one style must dominate, and unfortunately the one I didn't want was the one that exerted the most influence on my code. If I was to do it again (or refactor what I currently have), I could probably make it work alot better, but it's just something to be aware of.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement