zap
zap copied to clipboard
Find libopenssl instead of libssl
I don't know if this is an issue on all platforms, and might require some editing if it's not, but on MacOS building fails when trying to link openssl.
zig build-lib facil.io Debug native: error: error: unable to find Dynamic system library 'ssl' using strategy 'paths_first'. searched paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libssl.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libssl.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libssl.so
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libssl.a
error: unable to find Dynamic system library 'crypto' using strategy 'paths_first'. searched paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libcrypto.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libcrypto.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libcrypto.so
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib/libcrypto.a
Changing the one line fixes the issue.
Thx for this. Not sure this is the correct solution, tho. I think it used to work on my mac as is. I would at least make the change platform dependent. You can see it in build.zig: if (target.result.os.tag == .windows) { ...
This is the change we made in our repo to support building on macOS. Unfortunately the way macOS / Xcode links these libraries is a bit of a mess.
// link in libopenssl and libcrypto on demand
if (use_openssl) {
switch (@import("builtin").os.tag) {
.linux => {
lib.linkSystemLibrary("ssl");
lib.linkSystemLibrary("crypto");
},
else => {
lib.linkSystemLibrary2("libssl", .{ .use_pkg_config = .force });
lib.linkSystemLibrary2("libcrypto", .{ .use_pkg_config = .force });
},
}
}