why there is an error of undefined reference on raylib?

I have tried serval times, but it won’t work.

The code that I used is

gcc main.c -o main.exe -O1 -Wall -std=c99 -Wno-missing-braces -I E:\Dev\w64devkit\i686-w64-mingw32\include -L E:\Dev\w64devkit\i686-w64-mingw32\lib -lraylib

and the error was

E:\Dev\w64devkit\bin/ld.exe: C:\Users\jake\AppData\Local\Temp\cc8QGLal.o:test.c:(.text+0x26): undefined reference to `InitWindow'
E:\Dev\w64devkit\bin/ld.exe: C:\Users\jake\AppData\Local\Temp\cc8QGLal.o:test.c:(.text+0x32): undefined reference to `SetTargetFPS'
E:\Dev\w64devkit\bin/ld.exe: C:\Users\jake\AppData\Local\Temp\cc8QGLal.o:test.c:(.text+0x37): undefined reference to `WindowShouldClose'
E:\Dev\w64devkit\bin/ld.exe: C:\Users\jake\AppData\Local\Temp\cc8QGLal.o:test.c:(.text+0x47): undefined reference to `IsMouseButtonDown'
E:\Dev\w64devkit\bin/ld.exe: C:\Users\jake\AppData\Local\Temp\cc8QGLal.o:test.c:(.text+0x50): undefined reference to `GetMouseDelta'
E:\Dev\w64devkit\bin/ld.exe: C:\Users\jake\AppData\Local\Temp\cc8QGLal.o:test.c:(.text+0x57): undefined reference to `CloseWindow'
collect2.exe: error: ld returned 1 exit status'

how can I fix this problem?

  • Just a little nitpicking: The “code” that you use isn’t the code, it’s the command you use to build the code. With that said, it “should”™ work, since you link with the right library (unless you have more libraries named raylib in other locations). Are those the only messages you get? Please copy-paste the complete and full text from the console-window or build-log window into your question.

    – 




  • How and where did you install raylib?

    – 

  • Please provide enough code so others can better understand or reproduce the problem.

    – 
    Bot

Please check the library exist because this’s a link error.

Where did you install the library? According to the manual, it should be usually under C:\raylib.
https://github.com/raysan5/raylib/wiki/Working-on-Windows

Leave a Comment