#What are specific steps to be able to use a library like sdl2?
1 messages · Page 1 of 1 (latest)
idk either, but iirc there small projects that do this on github that may be just enough of an example to get it done. Havent watched it yet but Dude the Builder has been pretty useful and he has a videos on the general subject:
https://youtu.be/dHmw-424CMY?si=YkZ_g9OlY6ecX-6E
Help me create more content like this!
https://www.paypal.com/donate/?hosted_button_id=Y6DEFHEEWVBXJ
Zig's interoperability with C is seamless and top-notch. You can integrate C code directly in your Zig code, or you can compile C to a library and then link that library to Zig. In this episode we cover both approaches and as a bonus, how to com...
Help me create more content like this!
https://www.paypal.com/donate/?hosted_button_id=Y6DEFHEEWVBXJ
You can add Zig dependencies to your project by first defining them in the build.zig.zon file, then adding them to the parts of your project that need them via the build.zig file. In this episode, we cover a simple example of using a dependency ...
Help me create more content like this!
https://www.paypal.com/donate/?hosted_button_id=Y6DEFHEEWVBXJ
Zig's build system allows you to define options that your users can specify at build time via command line flags. You can then use these options to make build-time conditional compilation decisions and even propagate and make available these opt...
I have not tested it, but you don't have to use the package manager. If you initialized your project with zig init-exe:
-> build.zig
// [...]
exe.linkSystemLibrary("SDL2");
// [...]
-> main.zig
const sdl = @cImport({
@cInclude("SDL2/SDL.h");
});
// [...]
this assumes you have the headers(I think they are called this way?)/package installed on your system. I'm very new to zig or C, and you might need to adjust the paths, but this worked with raylib for me.
I tried both importing sdl manually and using zsdl. The latter worked much better for me
zsdl?
SDL2 is already installed on my system but I still am getting issues saying
zig build-exe hello-zig Debug native: error: error: unable to find Dynamic system library 'sdl2' using strategy 'paths_first'. searched paths: none
try all capital letters "SDL2"
this is how my build.zig looks
tried SDL_GETPLATFORM() and it returned Linux so I guess it works
tried
:/
on rust as a dependency it works fine, so sdl2 is deffo correctly installed
Dont know what could be wrong...
https://github.com/zig-gamedev/zig-gamedev/tree/main/libs/zsdl
it's not yet packaged for use with the zig package manager and instead expects you to vendor the library files directly, but currently it's probably the least painful option for depending on SDL2
hmmm interestingly painful
you're trying to clone a subdirectory of the repo, the repository url should be http://github.com/zig-gamedev/zig-gamedev.git
Wait... searched pathes: none?
Something is very wrong - it gives me the pathes it searched there when I had a typo or something... VERY weird