Closed jarrodldavis closed 8 years ago
Okay so I've tried on a fresh El Capitan install with Xcode 8 Beta 6 and the necessary Homebrew dependencies (libsodium
and openssl
) and I'm getting the same errors.
Swift Package Manager probably cannot find openssl installed by brew. You probably need to force-link openssl with brew:
$ pkg-config --cflags openssl
$ brew link openssl
Warning: openssl is keg-only and must be linked with --force
Note that doing so can interfere with building software.
$ brew link --force openssl
Linking /usr/local/Cellar/openssl/1.0.2h_1... 1601 symlinks created
$ pkg-config --cflags openssl
-I/usr/local/Cellar/openssl/1.0.2h_1/include
Also verify that libsodium is known to pkg-config
:
$ brew install libsodium
==> Downloading https://homebrew.bintray.com/bottles/libsodium-1.0.10.el_capitan
Already downloaded: /Users/bouke/Library/Caches/Homebrew/libsodium-1.0.10.el_capitan.bottle.tar.gz
==> Pouring libsodium-1.0.10.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/libsodium/1.0.10: 67 files, 1.1M
$ pkg-config --cflags libsodium
-I/usr/local/Cellar/libsodium/1.0.10/include
I intend to include the xcodeproj as well, which comes with already defined search paths for the libraries.
Note that there's an issue with encryption (CryptoSwift) that results in pairings not being able to establish (say ~75% of the time). So if pairing does not succeeds on the first try, try a few times more.
Note 2 this project is in its infancy and is in flux. Feel free to lend a hand.
Attempting to force link OpenSSL results in this:
Jarrods-MacBook-Pro:HAP jarrodldavis$ brew link --force openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
And I've tried swift build -Xcc -I/usr/local/opt/openssl/include -Xcc -L/usr/local/opt/openssl/lib
to no avail.
As of https://github.com/Homebrew/brew/pull/597 it's no longer possible to force link openssl. The compiler flags look allright, but are not picked up here as well. We should probably report this issue upstream. Apart from downgrading homebrew or symlinking openssl yourself, I don't know of any workaround for the moment.
Well I replaced your OpenSSL package with the one provided by IBM, fixed some operator errors in Sources/CryptoSwift/Operators.swift
, and used swift build -Xcc -I/usr/local/opt/openssl/include
.
It gets all the way to hap-server
and then this happens:
Compile Swift Module 'hap_server' (1 sources)
Linking ./.build/debug/hap-server
ld: library not found for -lcrypto for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/jarrodldavis/dev/misc/HAP/.build/debug.yaml
The issue with using their module is that they don't import crypto.h
, so the crypto module isn't available. What I found as a workaround is symlinking the libraries to something on pkg-config's path:
ln -s /usr/local/opt/openssl/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig
Okay, that works!
I've been trying to build this repo for several days now and even with your updates to support Xcode 8 Beta 6, I'm still getting a lot of build errors.
The first thing I get is a problem with OpenSSL:
Then I get hundreds (literally hundreds!) of "redefinition" errors like this:
Are you building this on macOS Sierra? That's the only reason I can think of that could be drastically different between our environments that could be causing this issue.