1

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.

1 Answers1

0

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.stack.imgur.com/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.

GreenDev
  • 13
  • 7