Tech Setup1
We'll use the most-up-to-date tools to build/develop C++ projects:
- Install/Update Visual studio 2022 - Community Edition2 (make sure checkboxes at right panel are checked, especially 'MSVC' and 'Windows 10 SDK')
- Install/Update CMake (official site) (use the
.msi
, and make sure you install CMake after installing VS, not before), - Install/Update Git (official site),
- Install/Update Powershell (Microsoft Store)
- Needs VPN (in some countries 🤔)
- Or from GitHub repo
- Add
cmake
andgit
to PATH environmental variable (for system, not for user), these are the default pathsC:\Program Files\CMake\bin
(at top of the list),C:\Program Files\Git\bin
- Add
msbuild
to PATH,- To find
msbuild.exe
: Open Visual Studio 2022 -> Tools menu -> Command Line -> Developer Command Prompt -> Runwhere msbuild
-> copy the path3 and add it to PATH - This allows you to build any
.sln
from command-line (ex. powershell), so you don't have to open the solution (.sln) in VS in order to build the projects (especially if you do clone opensource projects a lot 😄)
- To find
- NOTES:
- In some cases, after pwsh.exe is not recognized by cmd.. to verify, open cmd, type
pwsh --version
, if you got an error message, open windows start menu -> pwsh -> open file location -> copy the location and add it to PATH (see next step) - When changing PATH entries, you should restart open sessions (restart visual studio if opened, restart powershell if opened)
- In some cases, after pwsh.exe is not recognized by cmd.. to verify, open cmd, type
Run the following commands in Powershell (one by one)
cd ~\desktop # go to desktop
mkdir opensource && cd opensource
git clone https://github.com/MuhammadSulaiman001/opengl-lab
cd opengl-lab\OpenGLab # move to .sln location
msbuild OpenGLab.sln # build the solution
Now, you can find the build output inside project folder (ex. LabDemos.exe
can be found in LabDemos\x64\Debug\
folder)
Build projects in LearnOpenGL repo
cmake --version # verify cmake is installed
git --version # verify git is installed
cd ~\desktop\opensource
mkdir opensource && cd opensource
git clone https://github.com/JoeyDeVries/LearnOpenGL
cd LearnOpenGL
mkdir build && cd build # create/move to build directory
cmake .. # build the build system :)
msbuild LearnOpenGL.sln # It took 4 minutes on my device to build all the projects
cd ..\bin # move to output location
explorer . # open in windows explorer!
# now, you can check project's output, run .exe files
You can find .exe files in projects folders..
Great, you have built/run many opengl projects, without writing any C++ code (or opening visual studio at all).
- Get familiar with the build system and the IDE
- Learn C++
- Learn OpenGL
- Learn the basics of Git, Poweshell 7.x.x and CMake
Footnotes
-
Please note that the following configuration is not opengl-specific! ↩
-
If you have some other C++ compiler installed (ex. MinGW, CLang, etc..) please uninstall them before installing VS (this will avoid you some CMake errors) ↩
-
There might be 2 paths, one for visual studio and one for .NetFramework, choose the visual studio one. ↩