Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 2.73 KB

COMPILING.md

File metadata and controls

59 lines (42 loc) · 2.73 KB

Compiling DieKnow

Ensure you are on a Windows machine before attempting to compile!

1) Installing gcc

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
  1. Download the MSYS2 installer

  2. Open the MSYS2 installer and follow the instructions to install MSYS2. Copy the path that you inputted when asked. You'll need it later.

  3. Once it has finished installing, open up the newly installed app "MSYS2 UCRT64", found by typing the name after pressing the Windows key.

  4. Type the following command to synchronize the MSYS2 package database. The terminal will close, and you'll have to reopen it again.

    pacman -Syu
  5. Once the terminal reopens, type the following command to install g++

    pacman -S mingw-w64-x86_64-gcc
  6. 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.

Adding to PATH

  1. Press the Windows key and type "Edit environment variables for your account".
  2. On the top half of the screen, go to "Path".
  3. Press Alt-E and then Alt-N
  4. Paste the installation directory of MSYS2 you copied when installing MSYS2 and then type mingw64\bin to complete the path.
  5. 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.

2) Using the compilation command

  1. Use cd to cd to the directory where you downloaded DieKnow.

  2. 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
  3. 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.