0

I downloaded a raylib repository and added it as a static library to my project folder, then I made a short test programm but when I tried to compile and link it, it showed "undefined reference to function". My Test Programm Main.cpp is:

#include <iostream>
#include <raylib.h>

using namespace std;
  
int main()
{
    
    InitWindow(800, 500, "Elden-Tactic");
    do{
        BeginDrawing();
            ClearBackground(RAYWHITE);
            DrawRectangle(10, 50, 100, 100, BLACK);
        EndDrawing();
    }while(!WindowShouldClose());
    
}

My Command Prompt Lines to build it are:

g++ -Wall -I C:/Users/j-bro/raylib-Test/raylib-4/include/ -c Main.cpp //Compile

g++ -Wall -L C:/Users/j-bro/raylib-Test/raylib-4/lib -lraylib -o Main Main.o //Link

I am quite a newbie when it comes to compile things not just with one click or working with Command Lines etc, so please considerate that. Did I forget something or wrote anything wrong? I also have Include Path edited so it can find both, the Header File and the Static Library.

I tried different Command Prompt Lines as well that I could find on the Internet, but nothing seemed to work.

463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
  • 1
    "undefined reference to function" ? Thats the error message? There is no `function` in your code. Please post a [mcve] and include the complete error message – 463035818_is_not_an_ai Feb 23 '23 at 19:20
  • The error Message is: – JanniB HD Feb 23 '23 at 20:00
  • C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Main.o:Main.cpp:(.text+0x93): undefined reference to `WindowShouldClose' and that for every raylib function i Used – JanniB HD Feb 23 '23 at 20:00

0 Answers0