Skip to content

Commit b1c8c79

Browse files
Akuliandrewrk
authored andcommitted
Add /lib/x86_64-linux-gnu or similar to default system library search paths
this makes compiling with libraries like zlib and ncurses easier
1 parent 080dd27 commit b1c8c79

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

std/build.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ pub const Builder = struct {
372372
.abi = builtin.abi,
373373
}).linuxTriple(self.allocator);
374374

375+
// TODO: $ ld --verbose | grep SEARCH_DIR
376+
// the output contains some paths that end with lib64, maybe include them too?
377+
// also, what is the best possible order of things?
378+
375379
self.addNativeSystemIncludeDir("/usr/local/include");
376380
self.addNativeSystemLibPath("/usr/local/lib");
377381

@@ -380,6 +384,11 @@ pub const Builder = struct {
380384

381385
self.addNativeSystemIncludeDir("/usr/include");
382386
self.addNativeSystemLibPath("/usr/lib");
387+
388+
// example: on a 64-bit debian-based linux distro, with zlib installed from apt:
389+
// zlib.h is in /usr/include (added above)
390+
// libz.so.1 is in /lib/x86_64-linux-gnu (added here)
391+
self.addNativeSystemLibPath(self.fmt("/lib/{}", triple));
383392
},
384393
}
385394
}

0 commit comments

Comments
 (0)