Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help with game crashing on startup when run with an installer  (Read 1683 times)

0 Members and 1 Guest are viewing this topic.

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Help with game crashing on startup when run with an installer
« on: August 30, 2023, 07:25:52 am »
I am wondering if anyone here is familiar with issues when trying to make your game playable by others/distribute it.

I have my Debug and Release configurations both targeting x64, and made sure I am using 32 bit libraries for everything. The game works when I run it from visual studio in both Debug and Release configurations. I created a Setup Installer project, following https://learn.microsoft.com/en-us/cpp/ide/walkthrough-deploying-your-program-cpp?view=msvc-170. This Setup also builds without any errors or warnings.

However both on my PC and on any other I've tested on, when I install the program using the .msi generated by the Setup Installer project (which also installs successfully), when I go to run the game the window comes up white for a second and then goes away on its own in release mode. In Debug mode it throws up a popup saying "Debug Error".

I assume something must be happening with the dependencies, but I don't see any log output or any kind of feedback on why the app crashed.

Does anyone have experience on how to debug something like this or what might be the issue?

Thanks!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Help with game crashing on startup when run with an installer
« Reply #1 on: August 30, 2023, 03:36:43 pm »
The first question I have is why you are distributing debug builds?

There are reasons for doing this but not for a final released project; obviously, this should be a release build.

With that said, it sounds like something isn't working in your program when separate from Visual Studio. Have you tried launching it from the .exe file while not having Visual Studio open? It might also need some Visual C++ runtime libraries if you haven't already installed them (so that programs can run outside of Visual Studio). Building statically combines those libraries into your .exe file but it becomes much bigger whereas runtime libraries can be used my multiple programs.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with game crashing on startup when run with an installer
« Reply #2 on: August 30, 2023, 03:55:35 pm »
Im not planning on distributing debug builds, I was just trying that since the release build .exe closes right after opening.

I just tested it and it seems to have the same behavior with or without Visual Studio open.

Can you elaborate how I would find out what run time libraries I am using? My installer seems to find all the dependencies and include them, I've attached what it looks like in the folder after the installer is done.

Should I be concerned I don't see SFML in there? I am using the static SFML libraries so I don't need extra dlls correct?



Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Help with game crashing on startup when run with an installer
« Reply #3 on: August 30, 2023, 05:05:46 pm »
The stand-alone runtime libraries that are needed depend on which version of Visual C++ you are using to build.
It looks like you can find the one you will need (for any system that runs your builds) here:
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

Remember that this library needs installing on a system before they can run your builds. This isn't a massive deal (I've seen many apps/games requiring these before installation) but you may want to have a way for end users to install it first (it shouldn't install if it's already on the system but if it does, it'll just replace/update it).

If you're using static (rather than dynamic) SFML libraries, you're including the libraries into your executable file so there would be no DLL (dynamically linked library). An exception is that the audio dll (openal32.dll) due to its licence.



Is "the same behaviour" the 'correct' behaviour? Does this mean that running the executable directly causes it run correctly? Have you tried it in a separate folder (with just the files you are wanting to distribute - not the installation version)?

Another thing to consider is if you're (accidentally) using an absolute path for some file, it'll likely fail to find it on other systems.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with game crashing on startup when run with an installer
« Reply #4 on: August 30, 2023, 05:41:35 pm »
By "same behavior" I meant that it crashes immediately with or without VS open.

Thank you for these notes, I will take a look at this. I don't think I have any absolute paths but it would be worth a check. I had thought that the Installer project I made in VS would include that Visual C++ redist, but maybe I'm missing a step there.

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with game crashing on startup when run with an installer
« Reply #5 on: August 30, 2023, 08:20:04 pm »
Does anyone know of any good guides besides https://learn.microsoft.com/en-us/cpp/ide/walkthrough-deploying-your-program-cpp?view=msvc-170 to walkthrough deploying a c++ program? I can't seem to find anything besides that one that walks through everything one would need to know. Or know of any books? I can't really figure out how I'm going to figure out what I don't know.

I have a feeling my error is due to the asset files not being installed anywhere, but its very hard to figure out what's going on, as it still crashes even if i specify my asset files as content and have the installer include content files.

Is there a way to get the program to dump errors to console?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Help with game crashing on startup when run with an installer
« Reply #6 on: August 30, 2023, 11:04:57 pm »
By "same behavior" I meant that it crashes immediately with or without VS open.

Ah, I didn't realise it was also crashing when you started it from Visual Studio as well. I was under the impression it was working; this could be a completely separate issue.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with game crashing on startup when run with an installer
« Reply #7 on: August 31, 2023, 12:07:17 am »
Sorry let me clarify:

Debug mode build&run from VS: works
Release mode build&run from VS: works

Setup Installer Debug mode, launch with VS open: instant crash
Setup Installer Release mode, launch with VS open: instant crash
Setup Installer Debug mode, launch with VS closed: instant crash
Setup Installer Release mode, launch with VS closed: instant crash

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with game crashing on startup when run with an installer
« Reply #8 on: August 31, 2023, 12:37:54 am »
I was able to create and print to a console using:

AllocConsole();
freopen("CONOUT$", "w", stdout);
std::cout << "This works" << std::endl;
std::cout << "App Started" << std::endl;
 

This has helped me figure out that the issue is that my code is looking for an asset file which it can't find in the install location, and looking there I can see that the asset files are not there. I need to figure out how to get the installer to put asset files in the installation directory.

If anyone has experience/guides for that, it would be very welcomed :D

jace10

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Help with game crashing on startup when run with an installer
« Reply #9 on: August 31, 2023, 04:19:39 am »
I was able to get past this,

None of the MSDN articles I could find mentioned how to include things other than other libraries, but then I tried the "dumb" solution of just dragging everything I needed into the "File System on Target Machine" view in my setup project. Attached screenshot.

After doing that, running the installed exe works fine!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Help with game crashing on startup when run with an installer
« Reply #10 on: August 31, 2023, 12:17:15 pm »
One of the things I was asking is if it run from outside of Visual Studio before including the installer (by executing the executable). This is because resources/assets can often not be found from outside due to relative paths etc..

However, it looks like you've figured out your solution so that's great! :D
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*