This page describes how to make a stand-alone version of your Dragonfly game for Windows, as needed for the Stand-alone Game part of the Project 3 promotional materials. The result is a zipped folder that, when extracted, lets the player run your compiled game - no source code, engine or SFML install needed.
In the examples below, the game is called my-game.
Replace that with the name of your game.
For other platforms, see Mac or Linux.
When done, your stand-alone game folder should look like:
my-game\
my-game.exe <- release executable
run.bat <- launcher script
sfml-graphics-3.dll <- SFML .dll files
sfml-window-3.dll
sfml-system-3.dll
sfml-audio-3.dll
df-font.ttf
sprites\
sounds\
The Dragonfly library (e.g.,
libdragonfly-x64-release.lib) is a static library, so it is
built into my-game.exe and does not need to be copied.
Similarly, the SFML .lib files are only needed for building
- the game needs the SFML .dll files to run.
The commands below are for PowerShell. You can also do each step using File Explorer.
Build a Release version of your game. In Visual Studio, set the
Solution Configuration to Release and the platform to
x64, then build. Make sure the Release configuration links with
the release version of the SFML libraries (e.g.,
sfml-graphics.lib versus sfml-graphics-d.lib)
and a release version of Dragonfly.
Make a new, empty folder.
mkdir my-gameCopy in the executable, the Dragonfly font file and the needed
sprites and sounds. The executable is usually in
x64\Release\ under your project folder.
copy x64\Release\my-game.exe my-game\
copy df-font.ttf my-game\
Copy-Item -Recurse sprites, sounds my-game\Copy the SFML libraries (from SFML\bin) into the
game folder. Only copy the release versions (e.g.,
sfml-graphics-3.dll), not the debug versions
(e.g., sfml-graphics-d-3.dll). Most games need
graphics, window, system and
audio.
foreach ($l in "graphics","window","system","audio") {
copy C:\SFML\bin\sfml-$l-3.dll my-game\
}
To see exactly which DLLs your game needs, run
dumpbin /dependents my-game\my-game.exe from a
Developer PowerShell for VS prompt. (If you are using SFML 2,
the names are like sfml-graphics-2.dll and you also need
openal32.dll.)
Add a launcher script, my-game\run.bat. Dragonfly
loads the sprites, sounds and font from the current directory (and
writes dragonfly.log there), so the script changes to the
game folder first. That way, the game runs no matter where it is called
from.
@echo off
cd /d "%~dp0"
my-game.exe %*
Unlike Mac and Linux, Windows looks for DLLs in the same folder as the executable, so no other library path setup is needed.
Zip up the folder.
Compress-Archive -Path my-game -DestinationPath my-game.zip
Or, in File Explorer, right-click the folder and choose Compress to ZIP file (Windows 11) or Send to -> Compressed (zipped) folder (Windows 10).
Tip! A Release build from Visual Studio needs the
Microsoft Visual C++ runtime (e.g., VCRUNTIME140.dll and
MSVCP140.dll). Most Windows computers already have it, but
if the game complains that one of these is missing, the player needs to
install the Visual C++
Redistributable.
Make sure to test the installation by extracting in a different location (ideally, on another computer without Visual Studio or SFML) and verifying it can run!
mkdir C:\temp\test
Expand-Archive my-game.zip -DestinationPath C:\temp\test
C:\temp\test\my-game\run.bat
Include these steps (e.g., in a README) with your zipped game.
Download and extract my-game.zip. In File Explorer,
right-click it and choose Extract All…. Make sure to extract it
- running the game from inside the zip file will not work.
Run the game by double-clicking run.bat (or
my-game.exe) in the extracted folder. Or, from a command
prompt:
path\to\my-game\run.batSince the game is not signed, Windows may show a Windows protected your PC warning the first time. Click More info, then Run anyway.