CMake Windows installable outputting err even when none when debugging?

Issue

I am having an issue with a runtime error when running the executable created by the cmake --install command in the CMake Tutorial. The error I am receiving is:

NativeCommandExitException: Program "Tutorial.exe" ended with non-zero exit code: -1073741819.

I have followed the steps in the tutorial, including running cmake --install with the same toolchain and generator, and confirmed that the code is correct. I have also tested a simple “Hello World” application and confirmed that the cmake --install command is working correctly.

Steps to Reproduce

  1. Download the Official CMake Tutorial zip file here.
  2. Go to Step5 - Exercise 1 as listed in this part of the official CMake tutorial.
  3. Edit the Step5/CMakeLists.txt and MathFunctions/CMakeLists.txt as specified in Step5 - Exercise 1 (*Refer to the solutions given in the tutorial).
  4. Run cmake --install with the same toolchain and generator.
  5. Attempt to run the Tutorial.exe located in the bin folder of the output directory on your Desktop.

Answer

The error NativeCommandExitException: Program "Tutorial.exe" ended with non-zero exit code: -1073741819. indicates that the Tutorial.exe program is exiting with a non-zero exit code, which typically indicates an error.

To troubleshoot this issue, you can try the following steps:

  1. Check if any error messages or warnings are displayed during the cmake --install command. This can help identify any issues with the installation process.
  2. Make sure that you have the necessary dependencies installed, as specified in the tutorial. If any dependencies are missing, the program may fail to run correctly.
  3. Verify that the CMakeLists.txt files are correctly modified as specified in the tutorial. Double-check for any syntax errors or missing configurations.
  4. Check if the necessary files (such as the MathFunctions library) are being installed correctly during the cmake --install command. Confirm that the files are present in the correct locations.
  5. Try running the Tutorial.exe program from the command line using the full path to the executable. This can provide more detailed error messages that may help identify the issue.
  6. If all else fails, try re-downloading the Official CMake Tutorial zip file and repeating the steps from the beginning.

By following these troubleshooting steps, you should be able to identify and resolve the runtime error you are experiencing when running the Tutorial.exe program.