Hello,

I’ve installed the library called Raylib (https://www.raylib.com/). I followed the instructions to install the dynamic library. However, when compiling using gcc, including the raylib.h header dynamically in the source code produces an undefined reference error for every function I use from that library. That means that the library functions weren’t attached to the executable at runtime, so gcc didn’t find the right .so file.

To actually produce an executable, I have to use a shell script, that for some reason needs raylib’s source code path. But that goes against the point of installing a dynamic library, since the latter is used so that source code can be compiled without library functions, instead putting them somewhere else to be shared with other executables.

Can someone explain to me how gcc finds the .so files and if anyone has used raylib dou you understand what the shell script does?

  • 0x0@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    You’d need at least -L/path/to/raylib/dir where the raylib.so is and -lraylib in the compiler line. Order matters, search around.

    • o11c@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      If there’s a .pc file shipped, pkg-config can simplify your life by figuring out the flags for you.

  • modev@programming.devM
    link
    fedilink
    arrow-up
    1
    ·
    10 months ago

    I have installed gcc and Raylib from msys2.

    And compile my code with it using:

    gcc test.c -lraylib -lopengl32 -lgdi32 -lwinmm