Trying to compile the first lesson with InitWindow raylib

I’m having some issues when trying to compile the first lesson with raylib’s InitWindow on a macbook M1 Max, macOS Ventura 13.0.1

/usr/bin/clang++ -fcolor-diagnostics -fansi-escape-codes -g /Users/workmac/Projects/c++/Project/main.cpp -o /Users/workmac/Projects/c++/Project/main
Undefined symbols for architecture arm64:
  "_InitWindow", referenced from:
      _main in main-b31d98.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Build finished with error(s).

I’ve managed to get a bit further by reinstalling Homebrew in the Apple Silicon folders, as previously it was running from folders used on previous Intel machine.
The problem I’m having now is that probably the location in the project setup and the homebrew for M++ chips is not the same anymore and I’m getting the error:

[{
	"resource": "/Users/workmac/Projects/c++/new/main.cpp",
	"owner": "makefile-tools",
	"severity": 8,
	"message": "'raylib.h' file not found",
	"source": "gcc",
	"startLineNumber": 2,
	"startColumn": 10,
	"endLineNumber": 2,
	"endColumn": 10
}]

Raylib is installed by homebrew here:

/opt/homebrew/Cellar/raylib/4.2.0 (16 files, 3.7MB) *

You can add/change the location of Raylib that the template looks for by going into c_cpp_properties.json and modify the “IncludePath” section(s) for MacOS

That file is located in the .vscode folder in the project.

Thanks for the suggestion, will try that now!

hmm, it’s a bit confusing because actually, everything looks to be in place but still I’m getting that raylib.h can’t be found

Ok, just to make sure this isn’t just VSCode being dumb. Do you get that error when you try to compile?

Yes, unfortunately it’s not just VSC.

Starting build...
/usr/bin/clang++ -fcolor-diagnostics -fansi-escape-codes -g /Users/workmac/Projects/c++/new/main.cpp -o /Users/workmac/Projects/c++/new/main
/Users/workmac/Projects/c++/new/main.cpp:2:10: fatal error: 'raylib.h' file not found
#include "raylib.h"
         ^~~~~~~~~~
1 error generated.

Build finished with error(s).

Alright, try adding /opt/homebrew/Cellar/raylib/ to the includepath. I’m wondering if VSCode is having difficulty accessing the path originally specified in our template.

i’ve chaged to match the include folder inside raylib, I can even navigate from the #include to the raylib.h library, but still can’t compile…

Ok, I’ve removed it from homebrew, and using cLion and cMake got it to work.
For anyone having this issue, just create a new project using cMake and use the cmake config from here:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms