0

I am compiling a simple screen demo for Raylib in c using gcc and VCPKG as packet manager. When I compile I get several errors suggesting that GCC does not detect the Raylib functions inside the code such as InitWindow().

code:


//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
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;
}

error:

C:\Users\Main\Downloads\C\SDL2>gcc -I C:\Users\Main\Downloads\VCPKG\vcpkg\installed\x64-windows\include -L C:\Users\Main\Downloads\VCPKG\vcpkg\installed\x64-windows\lib Raylib.c -o a.exe -lraylib
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0x36): undefined reference to `_imp__InitWindow'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0x44): undefined reference to `_imp__SetTargetFPS'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0x4d): undefined reference to `_imp__BeginDrawing'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0x6f): undefined reference to `_imp__ClearBackground'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0xb1): undefined reference to `_imp__DrawText'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0xb8): undefined reference to `_imp__EndDrawing'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0xbf): undefined reference to `_imp__WindowShouldClose'
C:\Users\Main\AppData\Local\Temp\ccWcQiaB.o:Raylib.c:(.text+0xcd): undefined reference to `_imp__CloseWindow'
collect2.exe: error: ld returned 1 exit status
Saw
  • 115
  • 1
  • 16

0 Answers0