Dt: 24.08.2022
- Updated libs and include to Raylib v 4.2
How to make raylib static libraries for visual studio 2022 from raylib 4.0 source code.
Process is similar.
Download the source code from https://github.com/raysan5/raylib/releases
At this time of writing, raylib v4.0.0 is available. You can download the v4.0 source code zip file directly from this link: https://github.com/raysan5/raylib/archive/refs/tags/4.0.0.zip
Extract the zip file, your extracted folder looks similar to this
- After that run the
CMake guiand select the source and build folders. Then click onConfigureto show Cmake options. UncheckBUILD_EXAMPLESfrom the options.
Note: You need to installCmakeprior to this process.
- And click on
Generatebutton then chooseVisual Studio 17 2022andx64as platform. And click onFinishto close the configuration window.
And then click on
Open Projectbutton to openVisual studiosolution.From the opened solution, right click on
raylibproject and chooseSet as Startup Projectoption. Next you can delete all Cmake generated projects if you want. You can even delete Cmake generated unwanted build configs likeMinSizeReletc. We only needDebugandReleaseconfigurations.
- Now right click on
raylibproject and choosepropertiesset theOutputDirectory->$(SolutionDir)_Bin\$(Configuration)for better visibility for output files. For each platform (Debug and Release) make builds then the output folder looks like this. It containsraylib.libfiles for each configuration.
- For better organization, go to project directory, create a new folder
Outputand copyincludefolder. And create another folderlibin thatOutputfolder and copy newly generatedDebugandReleasefolders. The folder structure looks like this. We are gonna use these files in our raylib application/game.
- Now create a brand new
Empty C++ consoleproject. Createmain.cppfile in that project to activate C++ options.
- Open the newly created project in explorer, copy and paste the Output directory contents into the solution root directory.
Open project properties window and select
All Configurationsand set these options$(SolutionDir)includeunderC/C++ -> Additional Include Dirrectories$(SolutionDir)lib\$(Configuration)underLinker/General -> Additonal Library DirectoriesAdd these under
Linker/Input/Additional Depencies
raylib.lib
winmm.lib
opengl32.lib
kernel32.lib
gdi32.libAnd
$(SolutionDir)_Bin\$(Configuration)under General/Output Directory.Then copy this code into main.cpp file and make both Debug and Release builds. You will get the builds under
_Binfolder in project directory.
#include "raylib.h" //------------------------------------------------------------------------------------ // Program main entry point //------------------------------------------------------------------------------------ int main(void){// Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 600; InitWindow(screenWidth, screenHeight, "raylib - window tests"); SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key{// Update //---------------------------------------------------------------------------------- // TODO: Update your variables here //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(BLACK); DrawText("Success!!", 190, 200, 20, WHITE); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0} 








