Skip to content

Commit c8d1ade

Browse files
authored
Fix SDL_config.h errors on older glibc (#28)
glibc 2.37 and earlier does not support wcslcpy, wcslcat, strlcpy, and strlcat. Without implementing a more sophisticated detection, it is simpler to enable SDL's fallback functions for these often missing routines. example of affected systems: Linux Mint 21.3 and earlier Debian 12 (bookworm) and earlier Ubuntu 22.10 (kinetic) and earlier Fedora 37 and earlier Zorin 17.3 and earlier Also, updates README.md with some basic instructions.
1 parent 18ef2d8 commit c8d1ade

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
# SDL for Zig
2+
13
This is a fork of [SDL](https://www.libsdl.org/), packaged for [Zig](https://ziglang.org).
24
Unnecessary files have been deleted, and the build system has been replaced with `build.zig`.
35
The package provides version 2 of SDL. For version 3, consider https://github.com/castholm/SDL.
6+
7+
## Getting started
8+
9+
### Linking SDL2 to your project
10+
11+
Fetch SDL and add to your `build.zig.zon` :
12+
```bash
13+
zig fetch --save=SDL git+https://github.com/allyourcodebase/SDL
14+
```
15+
16+
Add this to your `build.zig` :
17+
```zig
18+
pub fn build(b: *std.Build) void {
19+
// ...
20+
21+
const sdl_dep = b.dependency("SDL", .{
22+
.optimize = .ReleaseFast,
23+
.target = target,
24+
});
25+
26+
// ...
27+
28+
exe.linkLibrary(sdl_dep.artifact("SDL2"));
29+
30+
// ...
31+
}
32+
```

build.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,8 @@ fn configHeader(b: *std.Build, t: std.Target) *std.Build.Step.ConfigHeader {
10871087
.HAVE_MEMMOVE = 1,
10881088
.HAVE_MEMCMP = 1,
10891089
.HAVE_WCSLEN = 1,
1090-
.HAVE_WCSLCPY = !is_musl,
1091-
.HAVE_WCSLCAT = !is_musl,
1090+
.HAVE_WCSLCPY = !is_linux,
1091+
.HAVE_WCSLCAT = !is_linux,
10921092
.HAVE__WCSDUP = 0,
10931093
.HAVE_WCSDUP = 1,
10941094
.HAVE_WCSSTR = 1,
@@ -1099,8 +1099,8 @@ fn configHeader(b: *std.Build, t: std.Target) *std.Build.Step.ConfigHeader {
10991099
.HAVE_WCSNCASECMP = 1,
11001100
.HAVE__WCSNICMP = 0,
11011101
.HAVE_STRLEN = 1,
1102-
.HAVE_STRLCPY = 1,
1103-
.HAVE_STRLCAT = 1,
1102+
.HAVE_STRLCPY = !is_linux or is_musl,
1103+
.HAVE_STRLCAT = !is_linux or is_musl,
11041104
.HAVE__STRREV = 0,
11051105
.HAVE__STRUPR = 0,
11061106
.HAVE__STRLWR = 0,

0 commit comments

Comments
 (0)