如何解决如何正确链接和编译raylib?
我正在用C ++编写并使用MinGW进行编译。我将这段代码从here复制并粘贴到了raylib.cpp中。
#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;
}
所以当我编译它时,我输入:
g++ -I"C:/path/to/raylib/src" raylib.cpp -o raylib.exe
在没有-I的情况下,我收到有关包含“ raylib.h”的错误,但是当我使用它时,会出现类似以下的错误:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x33): undefined reference to `InitWindow'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x3d): undefined reference to `SetTargetFPS'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x42): undefined reference to `WindowShouldClose'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x4e): undefined reference to `BeginDrawing'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0x76): undefined reference to `ClearBackground'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0xb7): undefined reference to `DrawText'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\cc3DNiLx.o:raylib.cpp:(.text+0xbc): undefined reference to `EndDrawing'
collect2.exe: error: ld returned 1 exit status
我该怎么做才能使“ raylib.h”文件不返回未定义的引用。我只链接到raylib / src文件夹,并且使该文件夹的机会为零。我该怎么办?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。