Vapor Mysql没有构建

Posted

技术标签:

【中文标题】Vapor Mysql没有构建【英文标题】:Vapor Mysql not building 【发布时间】:2016-10-25 19:37:21 【问题描述】:

运行时出现构建错误:

vapor build --mysql

在他们的 [网站][1] 中没有太多关于如何为此项目安装任何依赖项的文档。从堆栈跟踪来看,我似乎缺少“lmysqlclient”,我不确定我是否应该添加到链接器标志中,或者这是需要添加到蒸汽配置中的东西(我对蒸汽很陌生)。

这是堆栈跟踪:

computer:Server user$ swift build -Xswiftc -I/usr/local/mysql/include -Xlinker -L/usr/local/mysql/lib -Xswiftc -DNOJSON
Linking CLibreSSL
Compile Swift Module 'TurnstileCrypto' (3 sources)
Compile Swift Module 'Jay' (21 sources)
Compile Swift Module 'SocksCore' (14 sources)
Compile Swift Module 'Polymorphic' (2 sources)
Compile Swift Module 'PathIndexable' (2 sources)
Compile Swift Module 'libc' (1 sources)
Compile Swift Module 'Core' (28 sources)
ld: warning: directory not found for option '-L/usr/local/mysql/lib'
Compile Swift Module 'Node' (22 sources)
Compile Swift Module 'Socks' (5 sources)
Compile Swift Module 'Fluent' (35 sources)
Compile Swift Module 'Essentials' (2 sources)
Compile Swift Module 'TLS' (7 sources)
Compile Swift Module 'Console' (34 sources)
Compile Swift Module 'Leaf' (34 sources)
Compile Swift Module 'JSON' (8 sources)
Compile Swift Module 'Turnstile' (13 sources)
Compile Swift Module 'Random' (3 sources)
Compile Swift Module 'Cipher' (2 sources)
Compile Swift Module 'MySQL' (10 sources)
Compile Swift Module 'TurnstileWeb' (8 sources)
Compile Swift Module 'BCrypt' (1 sources)
Compile Swift Module 'Hash' (3 sources)
Compile Swift Module 'HMAC' (2 sources)
Compile Swift Module 'FluentMySQL' (2 sources)
Compile Swift Module 'URI' (10 sources)
Compile Swift Module 'Transport' (8 sources)
Compile Swift Module 'HTTP' (33 sources)
Compile Swift Module 'SMTP' (21 sources)
Compile Swift Module 'WebSockets' (14 sources)
Compile Swift Module 'Settings' (10 sources)
Compile Swift Module 'Cookies' (11 sources)
Compile Swift Module 'Cache' (3 sources)
Compile Swift Module 'Routing' (9 sources)
Compile Swift Module 'HTTPRouting' (5 sources)
Compile Swift Module 'Sessions' (6 sources)
Compile Swift Module 'Auth' (14 sources)
Compile Swift Module 'TypeSafeRouting' (3 sources)
Compile Swift Module 'Vapor' (86 sources)
Compile Swift Module 'VaporMySQL' (1 sources)
Compile Swift Module 'App' (3 sources)
Linking ./.build/debug/App
ld: warning: directory not found for option '-L/usr/local/mysql/lib'
ld: library not found for -lmysqlclient 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/10.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/user/test/Server/.build/debug.yaml

【问题讨论】:

您是否忘记添加指向网站的链接? Vapor 的人提到你实际上可以像这样为 vapor 命令添加前缀:github.com/vapor/mysql/issues/63 【参考方案1】:

ld: warning: directory not found for option '-L/usr/local/mysql/lib'

您似乎没有在该目录中安装 mysql 标头。你安装了mysql吗?你确定那是他们所在的地方吗?

【讨论】:

hombrew安装mysql的位置与linux不同。我希望 vapor 允许我们通过这些编译器标志【参考方案2】:

对于任何使用 Xcode 构建它并假设 mysql 已正确安装在您的机器上(我使用自制软件)的人,您需要在 Xcode 项目中的项目 > 构建设置 > 其他 Swift 标志下传入 -DNOJSON 标志。

在运行vapor xcode 并假设你的mysql 包提供者都是set up 之后打开项目并添加标志。

清理项目 (⌘K),您应该可以开始了。

这对我有用

【讨论】:

以上是关于Vapor Mysql没有构建的主要内容,如果未能解决你的问题,请参考以下文章

使用Swift 4.1向Heroku部署Vapor 3 beta应用程序的问题

使用Swift4+Vapor写后端-初体验

由于“错误:‘URLSession’类型的值没有成员‘数据’”,将 Vapor 应用程序部署到 Heroku 失败

Swift Vapor 服务器:如何在获取请求中返回嵌套字典?

在 MacOS 上将 Vapor 编译为独立应用程序

制作自定义 404 页面 Vapor 3