1

How does a Program that is already compiled create standalone .exe files without an apparent compiler? Example game making software like GameMaker that lets you create a game, add all the resources, images, scripts etc, and then lets you compile it into an exe file?

One of my theories is that there is already an .exe which is actually a game player and Gamemaker simply copies that exe and then renames it to the game name you've given, and your scripts are converted into opcodes and saved in a separate file, then this renamed .exe accesses the file and executes the opcodes like a virtual machine to play your game.

Another theory would be that the scripts are converted to c++ code by the gamemaker, which the gamemaker then calls the c++ compiler to automatically compile the code into an executable, because I know I can compile some c++ code using windows command line meaning that there is a c++ compiler already included hidden somewhere in windows.

3

Generally, you can append data to the end of an executable, and the executable will happily run as though nothing happened.

You can utilize this by having your executable read data from the end backwards, and take action accordingly. This is how self extracting zip files work.

Gamemaker most likely does not build an entire exe from scratch, but instead ships with a runtime and interpreter, which doesn't ever change. On load, the interpreter reads your scripts and resources from the end of the file, then executes them. This is how VB6 applications worked when made into .exes.

It's quite possible that you can open your exe in a program like 7z and see all your files packaged in there.

0

Well, how does your compiler do it?

After all, a compiler is an already compiled program that generates executibles. It takes some input - source code, game maker data, some diagram, whatever - and spits out some alternative form of that input. It can be an exe, but doesn’t need to be, the concepts are the same.

I am not familiar with gamemaker internals, but if I had to guess it likely behaves like your first theory. It has some well known scaffolding code that starts up, loads the game data (likely embedded in the exe) into some internal representation, and then runs it.

The gamemaker app is just a UI to define that internal representation and enough knowledge to write it to disk alongside executable bits that know how to process it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.