TERMINAL OUTPUT (when i try to debug and run):
Starting build…
/usr/bin/g++ -fdiagnostics-color=always -g /home/hala/Documenti/GitHub/axe_game/main.cpp -o /home/hala/Documenti/GitHub/axe_game/main
/usr/bin/ld: /tmp/cciViunJ.o: in function main': /home/hala/Documenti/GitHub/axe_game/main.cpp:6:(.text+0x31): undefined reference to InitWindow’
collect2: error: ld returned 1 exit status
Build finished with error(s).
The terminal process failed to launch (exit code: -1).
Terminal will be reused by tasks, press any key to close it.
The issue is not with your code, it is with the compiler. A similar thing happened with me in another course, I had to delete some file in a compiler folder to fix it. It can also happen if you have an old version of a compiler.
I even try to build raylib as a shared library, but I had the same issue.
Idk, if this could help:
I’m using Ubuntu 24.04 lts
and if I build from terminal using this line: cc main.cpp -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
I’m able to execute the code from the file created…
but I’m not able to debug and run from Vs Code
First of all I tryed to install raylib from Homebrew, and it gave me this error, then I found a post where a teaching assistant suggests to try to install, from the raylib github official repo, a shared library because the error could be caused by old version of the static lib, and I tryied , but nothing is changed.
both with ur template as in a new project where I copy pasted the raylib.h file and the library file.
edit:
I tryed to compile from terminal with g++ and gcc, but both the compiler gives me the same error:
main.cpp:(.text+0x22): undefined reference to `InitWindow’
edit2:
The only way to compile succesfully, even using the terminal is by execute this command: gcc <name_of_file_to_compile> -o <name_of_the_output_file> -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
Awesome! I’m glad that helped resolve the issue. Warnings can usually be ignored, though if you let me know what it is I may be able to help clear that as well.
There should be a “build debug” and/or “build release” option when choosing your build task. That option is not going to know that Raylib exists on your system or where to find it.
Huh, I’m not really getting any options so I’m not sure what you mean by that.
By looking around I discovered that if I go to “Run” and “Start Debugging” or F5 the project builds and runs without a problem. It’s only when I press the “debug arrow” in top right that I get the error. Kinda baffling, it never occurred to me that there could be any difference between the former and the latter.
For me, it seems to work best when I “prime” vs-code by Selecting Terminal > Run Task, then picking build debug. Then F5 and the debug arrow seem to behave themselves.
But also, VSCode is a weird program that I argue is probably trying to do too much. But that’s just my opinion
I tried it and it didn’t help
Debug arrow still throws that error but F5 and dropdown option builds normally lol.
This a real WTF moment if I’m being honest, but hey, I’m glad I discovered by accident that I can actually build my project. For the past 6 months I was under the impression that it was hopeless, I even reinstalled my whole system just to do a complete fresh install of raylib and VS code BECAUSE I THOUGH THE GOD DAMN DEBUG ARROW DOES THE SAME THING THE F5 AND DROPDOWN OPTIONS DO
Apologies, I lost my cool a little there.