Ensure you are on a Windows machine before attempting to compile!
You'll need a C++ compiler that supports C++20 in order to compile DieKnow's C++ functions. DieKnow has been developed on Microsoft Visual Studio using the gcc
compiler, but it can be developed on Visual Studio Code or any text editor with the following compilers:
- Microsoft Visual Studio C++ (MSVC)
- GNU Compiler Collection (gcc)
- Clang
-
Download the MSYS2 installer
-
Open the MSYS2 installer and follow the instructions to install MSYS2. Copy the path that you inputted when asked. You'll need it later.
-
Once it has finished installing, open up the newly installed app "MSYS2 UCRT64", found by typing the name after pressing the Windows key.
-
Type the following command to synchronize the MSYS2 package database. The terminal will close, and you'll have to reopen it again.
pacman -Syu
-
Once the terminal reopens, type the following command to install
g++
pacman -S mingw-w64-x86_64-gcc
-
Congratulations! You should have gcc installed on your machine. However, you'll need to add it to your system's PATH environment variable for it to be accessible.
- Press the Windows key and type "Edit environment variables for your account".
- On the top half of the screen, go to "Path".
- Press Alt-E and then Alt-N
- Paste the installation directory of MSYS2 you copied when installing MSYS2 and then type
mingw64\bin
to complete the path. - To check if it works, open up a Command Prompt window and type
g++
. If it says "no input files", you have successfully added g++ to your path.
-
Use
cd
to cd to the directory where you downloaded DieKnow. -
Open up a Command Prompt or Powershell window and type the following command to compile
api.cpp
into a DLL.g++ -Ofast -Wall -shared -std=c++20 -static -o src/dlls/api.dll src/api.cpp -lgdi32
-
If it works, type the following command to compile the GUI:
g++ -Ofast -Wall -shared -std=c++20 -static -o src/dlls/gui.dll src/gui.cpp -lgdi32 -lcomctl32
Note that if you use another compiler such as MSVC or CL, you will need to link additional libraries such as user32
or shell32
or even advapi32
.
Several options are used:
-Ofast
compiles into the FASTEST DLL as it possibly can.-Wall
enables all compile warnings.-std=c++20
sets the C++ standard to C++20.-static
links the DLL dependencies statically.-lgdi32
,-lcomctl32
link the needed libraries for Graphics Driver Interface and Windows Common Controls, respectively.