问候
我对C非常陌生。我想知道使用raylib制作基本窗口的最少步骤/代码。我正在使用 Linux 并遵循 github https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux上的步骤,但老实说,我不知道从哪里开始构建我自己的项目。示例中的基本窗口是否需要 cmake 或 make:core_basic_window.c,我可以编译(使用来自 github 的说明,但我不确定如何修改/简化我自己项目的代码) . 谢谢 : )
我试图从 github pull/project/directory 复制并粘贴此代码并在其上运行 gcc,但我收到错误消息:
// Filename: core_basic_window.c
#include "raylib.h"
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
无法编译:
########-ThinkPad-T430:~/Documents/c/bin/tmp$ gcc core_basic_window.c
/usr/bin/ld: /tmp/ccB5BYug.o: in function `main':
blah.c:(.text+0x2d): undefined reference to `InitWindow'
/usr/bin/ld: blah.c:(.text+0x37): undefined reference to `SetTargetFPS'
/usr/bin/ld: blah.c:(.text+0x3e): undefined reference to `BeginDrawing'
/usr/bin/ld: blah.c:(.text+0x65): undefined reference to `ClearBackground'
/usr/bin/ld: blah.c:(.text+0xa6): undefined reference to `DrawText'
/usr/bin/ld: blah.c:(.text+0xab): undefined reference to `EndDrawing'
/usr/bin/ld: blah.c:(.text+0xb0): undefined reference to `WindowShouldClose'
/usr/bin/ld: blah.c:(.text+0xbc): undefined reference to `CloseWindow'
collect2: error: ld returned 1 exit status