vapor 2 的 openssl / ctls 问题
openssl / ctls trouble with vapor 2
如何解决 Vapor 2 遇到的这些 OpenSSL/TLS 问题?他们阻止我在命令行和 Xcode.
中编译我的项目
在 SPM 构建期间:
note: you may be able to install ctls using your system-packager:
brew install ctls
note: you may be able to install ctls using your system-packager:
brew install openssl
SPM 构建失败:
Linking ./.build/debug/Run
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): /Library/Developer/Toolchains/swift-3.1-DEVELOPMENT-SNAPSHOT-2017-03-07-a.xctoolchain/usr/bin/swift-build-tool -f /Users/tanner/Desktop/PackageConfig/.build/debug.yaml
也在 SPM 中:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "shim.h"
^
/Users/tanner/Desktop/PackageConfigTwo/.build/checkouts/ctls.git-9210868160426949823/shim.h:4:10: error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
^
/Users/tanner/Desktop/PackageConfigTwo/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher+Method.swift:1:8: error: could not build Objective-C module 'CTLS'
import CTLS
^
在Xcode中:
/Users/tanner/PackageConfig/.build/checkouts/ctls.git-9210868160426949823/shim.h:4:10: 'openssl/conf.h' file not found
/Users/tanner/PackageConfig/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher+Method.swift:1:8: Could not build Objective-C module 'CTLS'
ld: library not found for -lssl
此错误表示 OpenSSL 未安装或未正确链接。这个问题有3种解决方法。
选项 1:使用 Vapor 工具箱(推荐)
安装最新版本的 Vapor 工具箱。
如果您已经安装了工具箱,请先尝试卸载它:
which vapor
rm -rf /path/to/vapor
1.1 安装 (macOS)
添加 Vapor 的 Homebrew Tap
brew tap vapor/homebrew-tap
更新 Homebrew 并安装工具箱。
brew update
brew install vapor
1.2 安装 (Ubuntu)
添加 Vapor 的 APT 存储库。
快速脚本
eval "$(curl -sL https://apt.vapor.sh)"
手动
wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | sudo apt-key add -
echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vapor.list
安装
sudo apt-get update
sudo apt-get install vapor
1.3 完成
您现在应该可以访问 vapor
程序并且应该安装所有必需的依赖项。
vapor build
vapor xcode
swift build
和相关命令现在应该也能正常工作了。
swift build
swift package generate-xcodeproj
选项 2:安装 Vapor 的 CTLS 包
2.1 安装 (macOS)
添加 Vapor 的 Homebrew Tap
brew tap vapor/homebrew-tap
更新 Homebrew 并安装 CTLS
brew update
brew install ctls
重新启动您的终端,重新生成您的 Xcode 项目(如果使用 Xcode),然后重试。
2.2 安装 (Ubuntu)
添加 Vapor 的 APT 存储库。
快速脚本
eval "$(curl -sL https://apt.vapor.sh)"
手动
wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | sudo apt-key add -
echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vapor.list
更新 APT 并安装 CTLS。
sudo apt-get update
sudo apt-get install ctls
2.3 完成
swift build
和其他命令现在应该可以正常工作了。
选项 3:手动安装和 Link OpenSSL 或等效程序
3.1 安装 (macOS)
安装 OpenSSL(或任何其他类似的 SSL 库)
brew install openssl
brew install libressl
3.2 安装 (Ubuntu)
安装 OpenSSL(或任何其他类似的 SSL 库)
sudo apt-get install libssl-dev
3.3 查找 Linker 标志
您可以使用 pkg-config
(在 brew 和 apt 上可用)来查找链接器标志或大多数包。
pkg-config <package-name> --cflags
pkg-config <package-name> --libs
但是,OpenSSL 通过 Homebrew 安装,因此不能与 pkg-config
一起使用。这些标志应该有效:
include: /usr/local/opt/openssl/include
libs: /usr/local/opt/openssl/lib
请注意,某些库将安装到 /usr/include
和 /usr/lib
中,不需要显式链接器标志。通过APT的OpenSSL就是这样安装的。
3.4 使用 Linker 标志
Linker 标志可以在 swift build
期间添加
swift build -Xswiftc -I/path/to/include -Xlinker -L/path/to/lib
它们也可以在 Xcode 项目生成期间添加。
swift package -Xswiftc -I/path/to/include -Xlinker -L/path/to/lib generate-xcodeproj
@tanner0101 你在这里 https://github.com/vapor/vapor/issues/937 的建议没有解决我的问题。我不仅在 High Sierra 上而且在 Docker 容器内的 Ubuntu 上都收到了 CTLS 丢失错误。
该项目可以手动执行,但 MySQL 不起作用。我认为这 https://github.com/vapor/vapor/issues/954 and this https://github.com/uchicago-cloud/mpcs51033-2017-spring-forum/issues/54 不仅仅是关于 Heroku 问题的部署。
如何解决 Vapor 2 遇到的这些 OpenSSL/TLS 问题?他们阻止我在命令行和 Xcode.
中编译我的项目在 SPM 构建期间:
note: you may be able to install ctls using your system-packager:
brew install ctls
note: you may be able to install ctls using your system-packager:
brew install openssl
SPM 构建失败:
Linking ./.build/debug/Run
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): /Library/Developer/Toolchains/swift-3.1-DEVELOPMENT-SNAPSHOT-2017-03-07-a.xctoolchain/usr/bin/swift-build-tool -f /Users/tanner/Desktop/PackageConfig/.build/debug.yaml
也在 SPM 中:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "shim.h"
^
/Users/tanner/Desktop/PackageConfigTwo/.build/checkouts/ctls.git-9210868160426949823/shim.h:4:10: error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
^
/Users/tanner/Desktop/PackageConfigTwo/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher+Method.swift:1:8: error: could not build Objective-C module 'CTLS'
import CTLS
^
在Xcode中:
/Users/tanner/PackageConfig/.build/checkouts/ctls.git-9210868160426949823/shim.h:4:10: 'openssl/conf.h' file not found
/Users/tanner/PackageConfig/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher+Method.swift:1:8: Could not build Objective-C module 'CTLS'
ld: library not found for -lssl
此错误表示 OpenSSL 未安装或未正确链接。这个问题有3种解决方法。
选项 1:使用 Vapor 工具箱(推荐)
安装最新版本的 Vapor 工具箱。
如果您已经安装了工具箱,请先尝试卸载它:
which vapor
rm -rf /path/to/vapor
1.1 安装 (macOS)
添加 Vapor 的 Homebrew Tap
brew tap vapor/homebrew-tap
更新 Homebrew 并安装工具箱。
brew update
brew install vapor
1.2 安装 (Ubuntu)
添加 Vapor 的 APT 存储库。
快速脚本
eval "$(curl -sL https://apt.vapor.sh)"
手动
wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | sudo apt-key add -
echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vapor.list
安装
sudo apt-get update
sudo apt-get install vapor
1.3 完成
您现在应该可以访问 vapor
程序并且应该安装所有必需的依赖项。
vapor build
vapor xcode
swift build
和相关命令现在应该也能正常工作了。
swift build
swift package generate-xcodeproj
选项 2:安装 Vapor 的 CTLS 包
2.1 安装 (macOS)
添加 Vapor 的 Homebrew Tap
brew tap vapor/homebrew-tap
更新 Homebrew 并安装 CTLS
brew update
brew install ctls
重新启动您的终端,重新生成您的 Xcode 项目(如果使用 Xcode),然后重试。
2.2 安装 (Ubuntu)
添加 Vapor 的 APT 存储库。
快速脚本
eval "$(curl -sL https://apt.vapor.sh)"
手动
wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | sudo apt-key add -
echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vapor.list
更新 APT 并安装 CTLS。
sudo apt-get update
sudo apt-get install ctls
2.3 完成
swift build
和其他命令现在应该可以正常工作了。
选项 3:手动安装和 Link OpenSSL 或等效程序
3.1 安装 (macOS)
安装 OpenSSL(或任何其他类似的 SSL 库)
brew install openssl
brew install libressl
3.2 安装 (Ubuntu)
安装 OpenSSL(或任何其他类似的 SSL 库)
sudo apt-get install libssl-dev
3.3 查找 Linker 标志
您可以使用 pkg-config
(在 brew 和 apt 上可用)来查找链接器标志或大多数包。
pkg-config <package-name> --cflags
pkg-config <package-name> --libs
但是,OpenSSL 通过 Homebrew pkg-config
一起使用。这些标志应该有效:
include: /usr/local/opt/openssl/include
libs: /usr/local/opt/openssl/lib
请注意,某些库将安装到 /usr/include
和 /usr/lib
中,不需要显式链接器标志。通过APT的OpenSSL就是这样安装的。
3.4 使用 Linker 标志
Linker 标志可以在 swift build
swift build -Xswiftc -I/path/to/include -Xlinker -L/path/to/lib
它们也可以在 Xcode 项目生成期间添加。
swift package -Xswiftc -I/path/to/include -Xlinker -L/path/to/lib generate-xcodeproj
@tanner0101 你在这里 https://github.com/vapor/vapor/issues/937 的建议没有解决我的问题。我不仅在 High Sierra 上而且在 Docker 容器内的 Ubuntu 上都收到了 CTLS 丢失错误。
该项目可以手动执行,但 MySQL 不起作用。我认为这 https://github.com/vapor/vapor/issues/954 and this https://github.com/uchicago-cloud/mpcs51033-2017-spring-forum/issues/54 不仅仅是关于 Heroku 问题的部署。