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

Find libopenssl instead of libssl #91

Closed
wants to merge 2 commits into from
Closed

Conversation

joeypas
Copy link
Contributor

@joeypas joeypas commented Apr 12, 2024

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.

@renerocksai
Copy link
Member

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

@dwolrdcojp
Copy link

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 });
            },
        }
    }

@joeypas joeypas closed this Jun 23, 2024
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

Successfully merging this pull request may close these issues.

3 participants