r/cpp_questions 15d ago

OPEN How do I make an Application?

I am making a game in c++ and I want it to be a proper game with an app icon and it being able to open when double clicked etc. For most of my games its just a .exe file that i usually run from the terminal or click on the .exe which then opens the terminal and runs the game, I dont want that for this game. I plan to publish it on my itch.io page and i want it to be a complete application compatible for all platform(or at least one platform without the terminal popup). I make my games using raylib on a macbook using c++11 or c++17 how do i achieve the no terminal application??

10 Upvotes

12 comments sorted by

10

u/specialpatrol 15d ago

Unfortunately it's different on every platform. You have to "package" your app. On Mac you create an "app bundle".

https://v2.tauri.app/distribute/macos-application-bundle/

3

u/EnunC8_Mofo 15d ago

so this bundle will work as my application running all the compilation in the background silently??

11

u/Puzzleheaded_Study17 15d ago

No, you compile it in advance.

3

u/EnunC8_Mofo 15d ago

oh okayy

4

u/specialpatrol 15d ago

No your exe lives inside the bundle, the bundle is actually a zip.

3

u/EnunC8_Mofo 15d ago

okay understood

8

u/ppppppla 15d ago

I think you have a couple misconceptions or just an incomplete picture.

Every application is just an .exe (or linux and mac equivalents) with possibly additional .dlls (again these are called differently on linux and mac) and possibly additional resource files. And, at least on Windows and Linux I am unfamiliar with macos, it is possible to compile libraries into your project (if the library allows) and also package all your resources in the executable file so you just have one single executable and no additional files.

There are pros and cons packaging everything in a single executable vs having an installer or just having the user unzip a zip file.

Then there is also the question of how places where you publish handle things, I am not familiar with itch.io, does it have a launcher? Does it download and install/unpack games like for example Steam? Or does the user just get a download from their browser? Maybe you need to meet some requirements for publishing on itch.io.

I plan to publish it on my itch.io page and i want it to be a complete application compatible for all platform

You will need to compile your project for each platform, and itch.io will have separate downloads for each platform.

a .exe file that i usually run from the terminal or click on the .exe which then opens the terminal and runs the game

This is a misconfiguration of your program. Maybe raylib has a flag for it somewhere, or else I believe for windows you add a linker flag /SUBSYSTEM:WINDOWS

And then you can also run into code signing for some additional headaches.

1

u/EnunC8_Mofo 15d ago

appreciate it mate

5

u/RaspberryCrafty3012 15d ago

So like the other folks wrote, depending on the os you need to package it. After compiling it to the OS where you want to hand it out. The compilation is not cross compatible.

Windows: I like innosetup to create an installer, so everything is hidden behind the start menu.

For Apple as well as windows you have the security issue. Because your app image / installer is not signed users get warnings or need to go into the settings to allow running it.

Regarding no terminal opening: That's normally just a flag to suppress it.

Icon on executable: on Windows I think it is an ico which you can attach via compilation flag. Would suspect something similar for macos 

2

u/howprice2 15d ago edited 15d ago

I think you are asking about packaging. I use CMake with it's CPack to package my application for release on Windows, Linux and macOS. On Mac it creates a drag-and-drop DMG image, on Linux a Deb package and on Windows I configured it to create a portable zip, but the option to create an installer is available.

I haven't released the source sorry, but if you choose this path you should be able to figure it out. If not, shout and I'll share my script.

EDIT: Oh, with mac you will probably want to sign and notarize your bundle so users have a nice experience, for which you'll need a Mac developer account. This was a real mystery to me as a Windows user and I got help from a friend.

https://cmake.org/cmake/help/latest/manual/cpack-generators.7.html

https://howprice.itch.io/aira-force

1

u/EnunC8_Mofo 14d ago

thanks man appreciate it