I am writing in C++ and using MinGW to compile. I copied and pasted this code from here into my raylib.cpp.
#include "raylib.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
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(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
So when I compile it I type:
g++ -I"C:/path/to/raylib/src" raylib.cpp -o raylib.exe
Without the -I I receive errors about including "raylib.h", but when I do use it I get errors like:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x33): undefined reference to `InitWindow'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x3d): undefined reference to `SetTargetFPS'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x42): undefined reference to `WindowShouldClose'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x4e): undefined reference to `BeginDrawing'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x76): undefined reference to `ClearBackground'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0xb7): undefined reference to `DrawText'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0xbc): undefined reference to `EndDrawing'
collect2.exe: error: ld returned 1 exit status
What can I do to make the "raylib.h" file not return undefined reference. I am only linking to the raylib/src folder and I made zero chances to that folder. What can I do?