Skip to content

How to make raylib static libraries for visual studio 2022 from raylib 4.0 source code.

Notifications You must be signed in to change notification settings

glory2win/raylib-visual-studio-2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

raylib-visual-studio-2022

Update

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.

  1. Download the source code from https://github.com/raysan5/raylib/releases

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

  3. Extract the zip file, your extracted folder looks similar to this

Extraction

  1. After that run the CMake gui and select the source and build folders. Then click on Configure to show Cmake options. Uncheck BUILD_EXAMPLES from the options.
    Note: You need to install Cmake prior to this process.

Cmake Gui

  1. And click on Generate button then choose Visual Studio 17 2022 and x64 as platform. And click on Finish to close the configuration window.

Generate

  1. And then click on Open Project button to open Visual studio solution.

  2. From the opened solution, right click on raylib project and choose Set as Startup Project option. Next you can delete all Cmake generated projects if you want. You can even delete Cmake generated unwanted build configs like MinSizeRel etc. We only need Debug and Release configurations.

Solution

  1. Now right click on raylib project and choose properties set the OutputDirectory -> $(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 contains raylib.lib files for each configuration.

Solution

Solution

  1. For better organization, go to project directory, create a new folder Output and copy include folder. And create another folder lib in that Output folder and copy newly generated Debug and Release folders. The folder structure looks like this. We are gonna use these files in our raylib application/game.

Solution

  1. Now create a brand new Empty C++ console project. Create main.cpp file in that project to activate C++ options.

Solution

  1. Open the newly created project in explorer, copy and paste the Output directory contents into the solution root directory.

Solution

  1. Open project properties window and select All Configurations and set these options

    $(SolutionDir)include under C/C++ -> Additional Include Dirrectories

    $(SolutionDir)lib\$(Configuration) under Linker/General -> Additonal Library Directories

    Add these under Linker/Input/Additional Depencies
    raylib.lib
    winmm.lib
    opengl32.lib
    kernel32.lib
    gdi32.lib

    And $(SolutionDir)_Bin\$(Configuration) under General/Output Directory.

  2. Then copy this code into main.cpp file and make both Debug and Release builds. You will get the builds under _Bin folder 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} 

Solution

**************** Happy Programming in C++ *******************

About

How to make raylib static libraries for visual studio 2022 from raylib 4.0 source code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages