【问题标题】:openssl / ctls trouble with vapor 2蒸汽 2 的 openssl / ctls 问题
【发布时间】:2017-08-21 14:02:11
【问题描述】:

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

【问题讨论】:

    标签: ssl openssl vapor


    【解决方案1】:

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

    选项 1:使用 Vapor Toolbox(推荐)

    安装最新版本的 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
    

    但是,OpenSSL 通过 Homebrew 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
    
    【解决方案2】:

    @tanner0101 你在这里的建议https://github.com/vapor/vapor/issues/937 并没有为我解决问题。我不仅在 High Sierra 上而且在 Docker 容器内的 Ubuntu 上都收到 CTLS is missing 错误。

    该项目可以手动执行,但 MySQL 不工作。我认为 https://github.com/vapor/vapor/issues/954https://github.com/uchicago-cloud/mpcs51033-2017-spring-forum/issues/54 不仅仅是 Heroku 问题上的部署。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-06
      • 2020-10-17
      • 2020-05-15
      • 2015-12-03
      • 1970-01-01
      • 2014-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多