ryupold / raylib.zig

Idiomatic Zig bindings for raylib utilizing raylib_parser
MIT License
222 stars 36 forks source link

Latest commit can't find raylib.h #37

Open figurae opened 9 months ago

figurae commented 9 months ago

Hi,

I tried using yesterday's commit (bd561b3689bc4e703f46bf1908633abb09680b4b), thanks for adapting to latest zig build changes (btw, I think usage section should now say raylib.addTo(b, exe, target.query, mode, .{});), but I can't seem to build it properly now. I'm getting this:

PS C:\Dev\deleteme> zig build run
info: include 'C:\Dev\deleteme\raylib\raylib\src' to deleteme
info: include 'C:\Dev\deleteme\raylib' to deleteme
info: include 'C:\Dev\deleteme\raylib\raylib\src' to raylib.zig
info: include 'C:\Dev\deleteme\raylib' to raylib.zig
info: linked raylib.zig
run
└─ run deleteme
   └─ zig build-exe deleteme Debug native 2 errors
raylib\raylib.zig:2:16: error: C import failed
const raylib = @cImport({
               ^~~~~~~~
referenced by:
    mGenImageFontAtlas: raylib\raylib.zig:760:14
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
C:\Dev\deleteme\zig-cache\o\0d5ecb46916cdb5d753079cf1d74c1e0\cimport.h:1:10: error: 'raylib.h' file not found
#include <raylib.h>
         ^
error: the following command failed with 2 compilation errors:
C:\Programy\zig\zig.exe build-exe C:\Dev\deleteme\zig-cache\o\c28dfb7d04bd2c30c1b41b11f46910da\raylib.lib C:\Dev\deleteme\zig-cache\o\32f84d208d30b2a3f8ffc03966fab633\raylib.zig.lib -ODebug -I C:\Dev\deleteme\raylib\raylib\src -I C:\Dev\deleteme\raylib --dep raylib -Mroot=C:\Dev\deleteme\src\main.zig -Mraylib=C:\Dev\deleteme\raylib\raylib.zig -lwinmm -lgdi32 -lopengl32 -lc --cache-dir C:\Dev\deleteme\zig-cache --global-cache-dir C:\Users\Althea\AppData\Local\zig --name deleteme --listen=-
Build Summary: 5/10 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run deleteme transitive failure
   ├─ zig build-exe deleteme Debug native 2 errors
   └─ install transitive failure
      └─ install deleteme transitive failure
         └─ zig build-exe deleteme Debug native (+2 more reused dependencies)
error: the following build command failed with exit code 1:
C:\Dev\deleteme\zig-cache\o\ae144d8a823e78ff0a47196651dee6a9\build.exe C:\Programy\zig\zig.exe C:\Dev\deleteme C:\Dev\deleteme\zig-cache C:\Users\Althea\AppData\Local\zig --seed 0x3d31fcd7 run

This is a clean repo with just raylib.zig, zig version 0.12.0-dev.2341+92211135f, Windows 11 22631.3085

ryupold commented 9 months ago

Hey, I am aware of this problem and a related issue is open in the examples repo.

I just don't know how to fix it. The include paths are added correctly but the linker cannot find the header files.

figurae commented 9 months ago

Oof, that's unfortunate. I've tried poking and prodding it, but it's out of my depth. So far, staying on ziglang/zig@c89bb3e141ee215add0b52930d48bffd8dae8342 has been my only solution.

Oh, and thanks for great bindings. Been using them for the past few months. :)

pierrec commented 8 months ago

I just ran into this and is quite frustrating. Should this package be part of Andrew's list of real world package uses?

kaihlavirta commented 8 months ago

I haven't figured out exactly what's going on here, but I had the same error message and the following worked for me:

  1. raylib/build.zig: Replace all std.build.FileSource.relative(...) to std.Build.LazyPath.relative(...)
  2. raylib/raylib.zig: Edit all @cInclude statements to have full paths to the header files. E.g. @cInclude("raylib.h") to @cInclude("C:\Dev\deleteme\raylib\raylib\src\raylib.h"). Note that "marshal.h" is in different dir from the other header files.
  3. raylib/marshal.h: Same as above - add full paths to the .h files in all #include statements

Yes, it's not pretty, but got my builds working until a proper fix comes around. I'm running on MacOS, so you may want to double check the correctness of the example path given above that it works in Windows.

Zig version 0.12.0-dev.11683+d5fc3c635.

pierrec commented 8 months ago

I haven't figured out exactly what's going on here, but I had the same error message and the following worked for me:

1. raylib/build.zig: Replace all `std.build.FileSource.relative(...)` to `std.Build.LazyPath.relative(...)`

2. raylib/raylib.zig: Edit all `@cInclude` statements to have full paths to the header files. E.g. `@cInclude("raylib.h")` to `@cInclude("C:\Dev\deleteme\raylib\raylib\src\raylib.h")`. Note that "marshal.h" is in different dir from the other header files.

3. raylib/marshal.h: Same as above - add full paths to the .h files in all `#include` statements

Yes, it's not pretty, but got my builds working until a proper fix comes around. I'm running on MacOS, so you may want to double check the correctness of the example path given above that it works in Windows.

Zig version 0.12.0-dev.11683+d5fc3c635.

Indeed this works (I only had to also update marshal.h to point at the right paths).

nezvers commented 8 months ago

I can confirm - std.Build.LazyPath.relative(...)

mobiuscog commented 7 months ago

This may be related: https://github.com/raysan5/raylib/pull/3835

figurae commented 7 months ago

I don't know if something's changed, but today std.build.FileSource.relative worked fine for me, I only had to put absolute paths in raylib.zig and marshal.h to use the latest builds (and update the signature of rlLoadFramebuffer).