Updated Using raylib in VSCode (markdown)

master
GhostOne 1 year ago
parent
commit
75f9278a43
1 changed files with 61 additions and 0 deletions
  1. +61
    -0
      Using-raylib-in-VSCode.md

+ 61
- 0
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. [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] [!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). 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_ _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 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.
<img width="805" alt="image" src="https://github.com/raysan5/raylib/assets/166855999/c85c2e46-6fff-41dc-b7ca-4b4fd734d88e">
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.<br>
If you have not modified anything to your homebrew install path, you will most likely find your raylib files in<br>
```
/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:<br>
```
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```
<img width="858" alt="image" src="https://github.com/raysan5/raylib/assets/166855999/3dd0b7cd-aa58-4eb3-b8d7-2259e3dc299a">
After that, select the run button at the bottom of the screen (not the one at the top)
<img width="1438" alt="Run Target Button Image" src="https://github.com/raysan5/raylib/assets/166855999/cee4b10e-8f4d-4c1b-b592-55183e81196b">

Loading…
Cancel
Save