From 75f9278a438af8d3069bb874346873f79a3b39e2 Mon Sep 17 00:00:00 2001 From: GhostOne <166855999+devghostone@users.noreply.github.com> Date: Sun, 21 Apr 2024 17:35:14 +0800 Subject: [PATCH] Updated Using raylib in VSCode (markdown) --- Using-raylib-in-VSCode.md | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/Using-raylib-in-VSCode.md b/Using-raylib-in-VSCode.md index 661b1ca..c401b8c 100644 --- a/Using-raylib-in-VSCode.md +++ b/Using-raylib-in-VSCode.md @@ -1,5 +1,7 @@ [VSCode](https://code.visualstudio.com/) is an excellent choice of code editor when it comes to raylib. Getting set up with a new VSCode project is easy. +# Windows + [!NOTE] Make sure you install Raylib from the official release binaries which you can find [here](https://github.com/raysan5/raylib/releases), rather than building Raylib from source (should work without changes on Windows if you install Raylib mingw release). @@ -83,3 +85,62 @@ Try launching by using the "Debug" launch configuration in the Debug tab or pres _or_ You can Build the game using **View > Command Palette** (or Ctrl + Shift + P), Type **Run Task** and press **Enter**. And Select the **Build Debug** option. A game executable will be created in the project folder. You can see any error in the console + +# Mac + +### Step 0: Environment Configurations + +Install brew, cmake and raylib, if you have not installed them yet. + +1. Follow the instructions on [brew](https://brew.sh) to install brew. +2. Install CMake through: ```brew install cmake``` +3. Install Raylib through : ```brew install raylib``` + + +### Step 1: VS Code Extension Configuration + +To make your life easier, it is best to use a combination of different extensions. Luckily, we can start this by installing this particular extension pack called [C/C++ Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack). It contains C/C++ utilities and CMake Tools. + +image + +You can read this article if you want to know more [CMake VScode Setup](https://github.com/gvcallen/CMake-VSCode-Tutorial) + +### Step 2 : CMakeLists Setup + +Assuming that you have a basic knowledge about CMakeLists, we will just briefly skim through process.
+If you have not modified anything to your homebrew install path, you will most likely find your raylib files in
+``` +/opt/homebrew/opt/raylib/include +``` +and dylib files in +``` +/opt/homebrew/opt/raylib/lib +``` + +First off, try to add the include files into your projects by:
+``` +find_path(RL_INCLUDE_DIR NAMES raylib.h PATHS /opt/homebrew/opt/raylib/include) +include_directories(${RL_INCLUDE_DIR}) +``` +This will remove error squiggle lines from your files if you have tried to include raylib.h + +Secondly, try to add the dylib library itself and link against it +``` +find_library(RL_LIBRARY NAMES raylib PATHS /opt/homebrew/opt/raylib/lib) +``` +Make sure you use target_link_libraries after you have use the add_executable +``` +target_link_libraries($YOUR_PROJECT ${RL_LIBRARY}) +``` + +### Step 3: Running the project + +**Make sure you have a main.c or main.cpp file to test whether if everything is linking properly or not** + +Press Ctrl+Shift+P to open up the command palette, and then search and select ```CMake: Configure``` +image + +After that, select the run button at the bottom of the screen (not the one at the top) +Run Target Button Image + +