Raylib编译器错误:架构的“未定义符号X86_64”
我是C的新手,并试图运行其中一个Raylib示例。但是编译时会给我以下错误:
Undefined symbols for architecture x86_64:
"_BeginDrawing", referenced from:
_main in Basic_window-642f03.o
"_ClearBackground", referenced from:
_main in Basic_window-642f03.o
"_CloseWindow", referenced from:
_main in Basic_window-642f03.o
"_DrawText", referenced from:
_main in Basic_window-642f03.o
"_EndDrawing", referenced from:
_main in Basic_window-642f03.o
"_InitWindow", referenced from:
_main in Basic_window-642f03.o
"_WindowShouldClose", referenced from:
_main in Basic_window-642f03.o
ld: symbol(s) not found for architecture x86_64
这是示例中使用的代码(我将其命名为basic_window.c):
#include "raylib.h"
int main(void)
{
InitWindow(800, 450, "raylib [core] example - basic window");
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
我已将raylib.h复制到与我的basic_window.c文件相同的目录中。我正在使用MacOS 12.3操作系统,并使用Clang作为编译器。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,假设您将Visual Studio用作编码环境。这些错误在X86项目中出现在BC中,因此首先要登上项目的顶部并击中X86并将其更改为X64并重新运行代码。 将头部安装回Visual Studio后,重新打开并在您的终端中键入它后,关闭并重新打开了Visual Studio。
首先,键入
git
命中输入,然后等待下一个类型
git克隆https://github.com/microsoft/vcpkg.git
hit Enter等待它安装下一个类型<代码> cd vcpkg 命中输入然后等待
下一个类型
./ bootstrap-vcpkg.sh
hit Enter输入然后一个类型
./ vcpkg Integrate intermate
hit hit Enter that next Next Next Next Next Next等待下 Next Next键入
./ vcpkg安装raylib:x64-windows
然后关闭并重新打开Visual Studio或文本编辑器,并且应该可以使用。
So assuming you are using Visual studio as your coding environment. These errors are appearing bc your in an X86 project so first head to the top of your project and hit X86 and change it to X64 and rerun the code. https://i.sstatic.net/80JP6.png.If this does not work then that probably means you installed the X86 version of raylib by default like me when I first installed Raylib. So if the previous method did not work install Git here https://git-scm.com/downloads.Them after installing head back into Visual studio and close and reopen Visual Studio once its done reopening and type this in your Terminal.
First, type
git
Hit enter then waitNext type
git clone https://github.com/Microsoft/vcpkg.git
Hit Enter Wait for it to installNext Type
cd vcpkg
Hit Enter then waitNext Type
./bootstrap-vcpkg.sh
Hit Enter then waitNext Type
./vcpkg integrate install
Hit Enter then waitNext Type
./vcpkg install raylib:x64-windows
Then close and reopen visual studio or text editor and it should work.