Okay I'm starting out with building my first program, coming from a handmade hero background, and I'm looking to make games in Raylib without using Xcode, just using Vim, and building from commandline. Unfortunately, I seem to be messing up some of the linking..
I've installed glfw with brew, and it's located: /usr/local/lib/libglfw.3.2.dylib
The other dependencies are in the same folder as test.cpp, I'm really not sure what's happening here..
Any clue? thanks!
Error:
````
test.cpp:11:20: error: expected expression
ClearBackground(RAYWHITE);
^
./raylib.h:292:28: note: expanded from macro 'RAYWHITE'
^
test.cpp:12:71: error: expected expression
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
^
./raylib.h:266:28: note: expanded from macro 'LIGHTGRAY'
^
2 errors generated.
````
Code:
````
int main()
{
路 int screenWidth = 800;
路 int screenHeight = 450;
路 InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
路 SetTargetFPS(60);
路 while (!WindowShouldClose()) // Detect window close button or ESC key
路 {
路 路 BeginDrawing();
路 路 路 ClearBackground(RAYWHITE);
路 路 路 DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
路 路 EndDrawing();
路 }
路 CloseWindow(); // Close window and OpenGL context
路 return 0;
}
````
Build line (I put everything in the kitchen sink here to try and get it to work)
clang++ -g -L/usr/local/lib -lraylib -lglfw3 -lGL -lopenal -lm -pthread -ldl test.cpp -o test
System: MacOS Sierra 10.12.6
Directory:
````
drwxr-xr-x 7 watchmyfeet staff 238 Oct 6 09:38 .
drwxr-xr-x 11 watchmyfeet staff 374 Oct 6 09:05 ..
-rwxr-xr-x 1 watchmyfeet staff 94 Oct 6 09:38 build.sh
-rw-r--r-- 1 watchmyfeet staff 590664 Oct 6 09:13 libraylib.a
drwxr-xr-x 21 watchmyfeet staff 714 Oct 6 09:11 raylib
-rw-r--r-- 1 watchmyfeet staff 65231 Oct 6 09:13 raylib.h
-rw-r--r-- 1 watchmyfeet staff 478 Oct 6 09:34 test.cpp
````
Seems related to C++ file compilation with clang++... CLITERAL definition don't seem to be defined correctly.
Have you tried compiling test.c and using clang?
You can also try commenting that line about CLITERAL if using clang++.
@raysan5 Appreciate the quick response!
Okay I've commented the CLITERAL lines using clang++ so that this line is active:
````
````
That almost worked, but now it looks like the system is looking for OPENGL functions, which according to the instructions for Mac OSX is not mentioned anywhere:
https://github.com/raysan5/raylib/wiki/Compile-for-OSX
(See Error at the bottom)
I see the same issue if I run clang as you recommended.
#clang++ -g -I/w/raylib_build/raylib/release/osx -L/usr/local/lib -L/w/raylib_build/raylib/release/osx -lglfw.3.2 -lraylib test.cpp -o test
clang -v -I/usr/local/lib -lglfw -L/w/raylib_build/raylib/release/osx -lraylib -I/w/raylib_build/raylib/release/osx test.c -o test
I'm a little worried about these strange issues so early on, but I'm willing to work through them if this can help people further down the line.. Thanks!
Errors:
Undefined symbols for architecture x86_64:
"_glActiveTexture", referenced from:
_DrawBuffersDefault in libraylib.a(rlgl.o)
_rlDrawMesh in libraylib.a(rlgl.o)
_GenTextureCubemap in libraylib.a(rlgl.o)
_GenTextureIrradiance in libraylib.a(rlgl.o)
_GenTexturePrefilter in libraylib.a(rlgl.o)
"_glAttachShader", referenced from:
_LoadShaderProgram in libraylib.a(rlgl.o)
"_glBindAttribLocation", referenced from:
_LoadShaderProgram in libraylib.a(rlgl.o)
"_glBindBuffer", referenced from:
_LoadBuffersDefault in libraylib.a(rlgl.o)
_UnloadBuffersDefault in libraylib.a(rlgl.o)
_UpdateBuffersDefault in libraylib.a(rlgl.o)
_DrawBuffersDefault in libraylib.a(rlgl.o)
_rlLoadMesh in libraylib.a(rlgl.o)
_rlUpdateMesh in libraylib.a(rlgl.o)
_rlDrawMesh in libraylib.a(rlgl.o)
...
"_glBindFramebuffer", referenced from:
_rlEnableRenderTexture in libraylib.a(rlgl.o)
_rlDisableRenderTexture in libraylib.a(rlgl.o)
_rlLoadRenderTexture in libraylib.a(rlgl.o)
_GenTextureCubemap in libraylib.a(rlgl.o)
_GenTextureIrradiance in libraylib.a(rlgl.o)
_GenTexturePrefilter in libraylib.a(rlgl.o)
_GenTextureBRDF in libraylib.a(rlgl.o)
...
"_glBindRenderbuffer", referenced from:
_GenTextureCubemap in libraylib.a(rlgl.o)
_GenTextureIrradiance in libraylib.a(rlgl.o)
_GenTexturePrefilter in libraylib.a(rlgl.o)
_GenTextureBRDF in libraylib.a(rlgl.o)
"_glBindTexture", referenced from:
_rlTextureParameters in libraylib.a(rlgl.o)
_rlLoadTexture in libraylib.a(rlgl.o)
_DrawBuffersDefault in libraylib.a(rlgl.o)
_rlUpdateTexture in libraylib.a(rlgl.o)
_rlLoadRenderTexture in libraylib.a(rlgl.o)
_rlGenerateMipmaps in libraylib.a(rlgl.o)
_rlDrawMesh in libraylib.a(rlgl.o)
@raysan5 Yes! I figured it out!
Found a guide here:
http://forum.raylib.com/index.php?p=/discussion/110/setup-guide-for-osx-w-atom
Looks like your forum is a good resource, that's a good sign :)
Here's my final build script:
````
clang++ -I/w/raylib_build/raylib/release/osx -L/usr/local/lib -L/w/raylib_build/raylib/release/osx -lglfw -lraylib -framework GLUT -framework OpenGL -framework Cocoa test.cpp -o test
clang -I/w/raylib_build/raylib/release/osx -L/usr/local/lib -L/w/raylib_build/raylib/release/osx -lglfw -lraylib -framework GLUT -framework OpenGL -framework Cocoa test.c -o test
````
I'm sure if this was added to the documentation for OSX, it would save someone else the trouble of getting stuck and possibly giving up early..
I've added the documentation to the wiki, things are going well now!
Hey @SethArchambault! Excuse me for the late response! I see you finally managed to ga through this issue! Great! :D
By the way, are you using latest develop branch? It contains raylib 1.8, I'm about to publish it...
Thank you very much for trying raylib and adding the info to the Wiki!
No I'm using master, would you recommend I switch to develop?
Liking the library so far! I'm coming from SDL - I never dared look at the underlying code there, but this code is very readable, so I'm able to adapt very quickly, so far so good!
I recommend using develop branch, it always implements latest changes and improvements. I also try to keep the branch stable. But right now most of the changes have been already merged into master because I'm preparing to publish next release...
raylib is similar to SDL in some things but as I developed it for education, I focused on source readibility and simplicity... one of the objectives was not only making it easy-to-use but also easy to understand internals.
Most helpful comment
I recommend using develop branch, it always implements latest changes and improvements. I also try to keep the branch stable. But right now most of the changes have been already merged into master because I'm preparing to publish next release...
raylib is similar to SDL in some things but as I developed it for education, I focused on source readibility and simplicity... one of the objectives was not only making it easy-to-use but also easy to understand internals.