使用Ubuntu 14.04
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
并尝试编译一个hello world Swift程序 .
print("Hello World!")
我已经验证了下载:
gpg --verify swift-2.2-SNAPSHOT-2015-12-10-a-ubuntu14.04.tar.gz.sig
gpg: Signature made Thu 10 Dec 2015 07:17:37 PM PST using RSA key ID 412B37AD
gpg: Good signature from "Swift Automatic Signing Key #1 <swift-infrastructure@swift.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7463 A81A 4B2E EA1B 551F FBCF D441 C977 412B 37AD
但是当我尝试编译hello world程序时,我收到此错误:
> swiftc hello_world.swift
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
如果我启动Swift REPL,我会收到类似的错误:
~$ swift
Welcome to Swift version 2.2-dev (LLVM 7bae82deaa, Clang 53d04af5ce, Swift 5995ef2acd). Type :help for assistance.
1> y = 6
opening import file for module 'SwiftShims': No such file or directory
1>
如果我按照指令given here使用"swift build"与"swiftc"编译Hello World Swift程序,我会得到一个不同的错误:
$ swift build
<unknown>:0: error: opening import file for module 'Swift': No such file or directory
swift-build: exit(1): ["/home/scooter/Programs/Swift/V2.2/bin/swiftc", "--driver-mode=swift", "-I", "/home/scooter/Programs/Swift/V2.2/lib/swift/pm", "-L", "/home/scooter/Programs/Swift/V2.2/lib/swift/pm", "-lPackageDescription", "/home/scooter/code/swift/helloworld-project/Package.swift"]
执行解释器:
$ swift hello_world.swift
给
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
strace尝试运行swift时出错:
$ strace -o /tmp/swift.log -- swift <(echo '1 + 1')
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
open(“/ home / user / Programs / Swift / V2.2 / lib / swift / linux / x86_64 / SwiftShims.swiftmodule”,O_RDONLY)= -1 ENOENT(没有这样的文件或目录)
2 回答
很抱歉,作为答案添加内容应该是真正的评论,但评论时间有点太长 .
据我所知,这确实与Swift on Linux: Make very first step work中描述的问题相同 . 我在业余时间一直在研究这个问题,但到目前为止还没有运气 . 问另一个问题的用户一直在追求它并且在那里有一些有趣的近期更新 .
一些事情要尝试:
看看快速解释器是否有效 . 只需输入
swift hello_world.swift
,看看会发生什么 . 我认为它不会起作用 . 如果没有,则运行strace
命令,如下所示:strace -o /tmp/swift.log -- swift <(echo '1 + 1')
并看看
/tmp/swift.log
. 查看无法找到的文件,尤其是在输出结尾附近 . 警告:即使在错误尚未能够重现的系统上,strace
输出也会显示很多No such file...
错误 .您还可以使用-v选项尝试swift和swiftrc以启用详细输出,并查看是否发现任何可疑内容 .
2016年2月更新:
前面提到的问题已经更新,可能解决问题:摆脱gcc,g,libgcc和libstdc的非标准安装 . 请参阅其他问题中的评论 .
2016年1月3日更新:
使用来自另一个问题讨论的线索,我已经能够通过从源安装gcc-5.1.0并将新安装的libstdc .so.6的位置预先挂起到LD_LIBRARY_PATH变量来重现该问题 .
问题可以通过以下方式解决:1)找出安装旧软件包的
libstdc++.so.6
的位置 . 在我的系统上:2)将
libstdc++.so.6
的位置添加到$LD_LIBRARY_PATH
:3)仔细检查swift二进制文件是否使用了正确的共享库:
现在,Swift可以在没有错误的情况下工作 .
您是否使用PPA或从源构建的构建链的任何库进行非标准安装?特别是libstdc . 请参阅Swift on Linux: Make very first step work的答案 .