Raylib编译器错误:架构的“未定义符号X86_64”

发布于 2025-01-29 08:46:54 字数 1182 浏览 4 评论 0 原文

我是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作为编译器。

I am new to c and trying to run one of the raylib examples. But when compiling it gives me the these errors:

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

This is the code used in the example (I named it 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;
}

I have copied raylib.h into my the same directory as my Basic_window.c file. I'm using macos 12.3 operating system and using clang as my compiler.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡少年 2025-02-05 08:46:54

因此,假设您将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 wait

Next type git clone https://github.com/Microsoft/vcpkg.git Hit Enter Wait for it to install

Next Type cd vcpkg Hit Enter then wait

Next Type ./bootstrap-vcpkg.shHit Enter then wait

Next Type ./vcpkg integrate installHit Enter then wait

Next Type ./vcpkg install raylib:x64-windows

Then close and reopen visual studio or text editor and it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文