Template by Chris. P taken from https://github.sydney.edu.au/cpol3526/ELEC1601-project-template
.vscode/- various adjustments for Visual Studio Code users for easier coding, such as updatingincludePathproperty so that VS Code can recognise our header files. Configurations available for Windows, macOS and Linux.- If you are developing on Windows, it is important to run
to avoid any strange conflicts that might come in commit diffs based on how Windows handle end-of-line characters, as well as setting your end-of-line sequence in your IDE to "LF" rather than "CRLF".
git config --global core.autocrlf false
- If you are developing on Windows, it is important to run
include/- folder containing header files (files that have the.hextension) - these usually contain code we want to import in other files.os/- folder which contains OS-specific files for compilation - for our case, this contains the SDL2 and SDL2_gfx files required just for Windows users.src/- folder containing source code files (files that have the.cextension) - these control how various components of our program work.Makefile- automatically compiles program and allows for easy checking of source code changes by using the Make build automation program.build_run_clean.sh- Bash shell script to to easily build, run, and clean up files after building program in one step for macOS and Linux - a really handy shortcut!build_run_clean.sh- a Batch script for Windows that does the same things asbuild_run_clean.sh, just, well, for Windows.
- GCC compiler for code
- On Windows, you will have to install a toolkit which supports this. The most common one is Mingw-w64 - instructions for installing are below.
- On macOS, if you have Command Line Tools for Xcode installed,
gccpoints to Clang to compile C programs, which effecitvely produces the same output. - On Linux,
gccshould be available from most distro's repositories.
- SDL2 (included in repository for Windows)
- SDL2_gfx (included in repository for Windows)
- Make program for interpreting makefiles
- On Windows, we will use
mingw32-makefrom Mingw-w64 - On macOS, this is usually preinstalled as
make - On Linux, this is available in most distro repositories as
make
- On Windows, we will use
Installation instructions are below:
To be able to compile the code in this repository, you will need to obtain a GCC compiler for Windows. The most popular one is included in the Mingw-w64 toolkit.
To install the latest version of GCC available for Windows with Mingw-w64, you can install the MSYS2 platform, which provides a variety of Unix tools for Windows, as well as a Unix-like shell for managing and updating them. The installation for MSYS2, as well as Mingw-w64, are available from their website: https://www.msys2.org/. Alternatively, you can also install Mingw-w64 as a standalone software: https://sourceforge.net/projects/mingw-w64/.
Once Mingw-w64 is installed, you will need to add the location of its executible files to the Windows PATH environment variable to allow for us to be able to access them by name from the command line. There is a good guide by Microsoft on their Visual Studio Code website on how you can do this: https://code.visualstudio.com/docs/cpp/config-mingw - simply scroll to
"Step 4" under "Prerequisites". If you installed Mingw-w64 as standalone software, the instructions will be the same - just ensure you are referring to the bin\ folder from the Mingw-w64 installation folder, rather than under the MSYS2 folder as in the guide.
SDL2 and SDL2_gfx files are included within this repository and are used when compiling on Windows, so after this, you are ready to compile and run!
If you don't already have Command Line tools for Xcode installed, install them by typing this into your terminal:
xcode-select --installAfter installing them, you will need to agree to the license in order to be able to use them - you can do so by running
sudo xcode-build -licenseand scrolling to the bottom and agreeing to the terms.
After this, if you don't have Homebrew or an equivalent package manager for macOS installed, install Homebrew by following their website: https://brew.sh/.
Using Homebrew, run:
brew install sdl2 sdl2-gfxTo compile the project, you will need configure the compiler to recognise the SDL2 libraries you installed from Homebrew.
To do this, you'll need to adjust the environment variables CPATH and LIBRARY_PATH in your shell profile (usually ~/.zshrc).
If you have an M1 Mac, add the following to your profile:
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/libIf you have an Intel Mac, add the following to your profile:
export CPATH=/usr/local/include
export LIBRARY_PATH=/usr/local/libAfter that you should be all set.
Ensure you have both gcc and make installed on your system. Once done, install SDL2 and SDL2_gfx from your distro's package manager.
Installing gcc and make with the build-essential metapackage:
sudo apt install build-essentialInstalling SDL2 and SDL2_gfx:
sudo apt install libsdl2-2.0-0 libsdl2-dev libsdl2-gfx-1.0-0 libsdl2-gfx-devInstalling gcc and make:
sudo dnf install gcc makeInstalling SDL2 and SDL2_gfx:
sudo dnf install SDL2 SDL2-devel SDL2_gfx SDL_gfx-develInstalling gcc and make with the base-devel metapackage:
sudo pacman -S base-develInstalling SDL2 and SDL2_gfx:
sudo pacman -S sdl2 sdl2_gfxDouble click the build_run_clean.bat script, or, alternatively, within PowerShell or Command Prompt, run
.\build_run_clean.batTo compile, run and clean up the compiled files in one step, simply run the following in your terminal from the project directory:
./build_run_clean.shTo compile the program without running, in your terminal, simply run mingw32-make on Windows, or make on macOS/Linux, in the project directory.
The compiled file will be saved to the bin folder as main on macOS and Linux, and main.exe on Windows.
To run the compiled program from your terminal:
./bin/main.\bin\main.exeYou can also remove the compiled files from your terminal by running mingw32-make clean on Windows, or make clean on macOS/Linux.
Marks awarded for both maze completion and completion time.