Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest commit can't find raylib.h #37

Open
figurae opened this issue Jan 27, 2024 · 8 comments
Open

Latest commit can't find raylib.h #37

figurae opened this issue Jan 27, 2024 · 8 comments

Comments

@figurae
Copy link

figurae commented Jan 27, 2024

Hi,

I tried using yesterday's commit (bd561b3), 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
Copy link
Owner

ryupold commented Jan 27, 2024

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
Copy link
Author

figurae commented Jan 27, 2024

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

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

@pierrec
Copy link

pierrec commented Feb 1, 2024

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

@kaihlavirta
Copy link

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
Copy link

pierrec commented Feb 1, 2024

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
Copy link

nezvers commented Feb 1, 2024

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

@mobiuscog
Copy link

This may be related: raysan5/raylib#3835

@figurae
Copy link
Author

figurae commented Mar 8, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants