简体   繁体   English

在Ubuntu上执行swift

[英]Execute swift on Ubuntu

I have downloaded the official release of Swift for my Ubuntu (16.04). 我已经为我的Ubuntu(16.04)下载了Swift的正式版本。 I would like to execute the file /path/to/swift/usr/bin/swift . 我想执行文件/path/to/swift/usr/bin/swift I type ./swift in this directory and exec format error appears. 我在此目录中键入./swift ,出现exec格式错误。 Doesn't matter whether I run it directly ( ./ ) or change $PATH and type swift anywhere the same error appears. 无论我是直接运行它( ./ )还是更改$PATH并在出现相同错误的任何地方输入swift

Is it a problem of Swift at all? 它是Swift的问题吗? Or is it the matter of my Ubuntu or this executable file? 或者是我的Ubuntu或这个可执行文件的问题?

UPDATE: the exact error is: bash: /swift-3.0/usr/bin/swift: cannot execute binary file: Exec format error 更新:确切的错误是: bash: /swift-3.0/usr/bin/swift: cannot execute binary file: Exec format error

The file command reports: file命令报告:

/swift-3.0/usr/bin/swift: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped

uname -a says: uname -a说:

Linux Lenovo-B570 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:05 UTC 2016 i686 i686 i686 GNU/Linux

Have a look at this tutorial for installing swift 3 from the Vapor framework docs. 看一下本教程,从Vapor框架文档安装swift 3

Try uninstalling swift and reinstalling using 尝试卸载swift并重新安装使用

curl -sL swift.vapor.sh/ubuntu | bash

from the link 从链接

Note: The install script adds Swift to your ~/.bashrc profile automatically. 注意:安装脚本会自动将Swift添加到〜/ .bashrc配置文件中。

You should be able to run swift files after running the above command. 运行上面的命令后,您应该能够运行swift文件。

*Note: If this doesn't work then we can identify that the installation is not the issue. *注意:如果这不起作用,那么我们可以确定安装不是问题。

You're trying to run a 64-bit executable (x86-64) on a 32-bit system (i686). 您正在尝试在32位系统(i686)上运行64位可执行文件(x86-64)。

That won't work (though you can usually do the reverse with a typical setup). 这不起作用(尽管通常可以通过典型的设置进行反向)。

You need to find and install a 32-bit version of Swift. 您需要找到并安装32位版本的Swift。 (Or, if practical, consider updating your system to use a 64-bit OS.) (或者,如果可行,请考虑更新系统以使用64位操作系统。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM