gpt4 book ai didi

ssl - vapor 2 的 openssl/ctls 问题

转载 作者:太空宇宙 更新时间:2023-11-03 12:40:06 24 4
gpt4 key购买 nike

如何解决我在使用 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

Xcode Failing with CTLS issues

最佳答案

此错误表示 OpenSSL 未安装或未正确链接。这个问题有三种解决方案。

选项 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:手动安装和链接 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 查找链接器标志

您可以使用 pkg-config(在 brew 和 apt 上可用)来查找链接器标志或大多数包。

pkg-config <package-name> --cflags
pkg-config <package-name> --libs

但是,通过 Homebrew 安装 OpenSSL cannot be linked因此不适用于 pkg-config。这些标志应该有效:

include: /usr/local/opt/openssl/include
libs: /usr/local/opt/openssl/lib

请注意,一些库将安装到 /usr/include/usr/lib 中,不需要显式链接器标志。通过 APT 的 OpenSSL 就是这样安装的。

3.4 使用链接器标志

可以在 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

关于ssl - vapor 2 的 openssl/ctls 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43070534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com