简体   繁体   中英

Install Swift language on CentOS (Red Hat)

I would like to use the Swift language at my workplace.
swift.org presently provides binaries only for Ubuntu 14.04 and 15.10
My workplace uses CentOS 6.6 (similar to Red Hat 6).

I tried running the binary, which produces this error message:

swift: error while loading shared libraries:
libedit.so.2: cannot open shared object file: No such file or directory

Build instructions for Ubuntu are here:
https://github.com/apple/swift/blob/master/README.md

Could someone provide binaries or build instructions for CentOS 64-bit?

I think your best bet is to build Swift from source. I have an article on how to do it here:

http://www.swiftprogrammer.info/swift_centos_2.html

It applies to CentOS 6.7, but most likely it will work on 6.6 just as well. Please note that the resulting software will have a more limited functionality than the Apple-provided binaries for Ubuntu:

  • Swift compiler (swiftc) and interpreter (swift) appear functional.
  • Swift build system and REPL don't work.

Nonetheless, this will provide you with enough Swift functionality to play with. Time permitting, I will try to provide my binaries on github in the next week or so.

Another thing to keep in mind is that Swift on Linux is work in progress at a very early stage. Besides, even though Swift as a language is available on Linux, a lot of modules that we take for granted on Mac OS X and iOS, such as Foundation, are far from being reasonably implemented on Linux, so don't expect to be able to do on Linux what can be done on Apple platforms yet. This applies even to the Apple-supplied binaries for Ubuntu.

Hope this helps, all the best!

我只是复制并重命名libedit.so到libedit.so.2,我试图将swift集成到Atom编辑器中,这个错误在构建项目时是错误的,现在它工作正常,以防你在构建项目时遇到问题缺少头文件,你必须按如下方式进行符号链接,sudo ln -s / usr / include / sys / / usr / include / x86_64-linux-gnu / sys

Debian and Red Hat are using different versioning for the same API

libedit.so.2 is available on rhel as libedit.so.0.0.42 . You can try to symlink to it.

cd /usr/lib64
ln -s libedit.so libedit.so.2

Unfortunately this will lead to the next blocker, at least on Centos 7.

 error: failed to launch REPL process: process launch failed: 'A' packet returned an error: -1

This is some kind of internal lldb error. It seems to occur in the past (before 15/12/03) only if lldb can't connect properly to the IOS Simulator.

Would have liked to post this as a comment but I can't due to not enough rep. Perhaps somebody with lldb knowledge can provide some tips on how to proceed further from this point.

In addition to mgmart's answer you might need to install bsdlib and symlink to the Red Hat versions of libicu18n.so and libicuuc.so

On fedora I used the following commands:

ln -s /usr/lib64/libicui18n.so.54 /usr/lib64/libicui18n.so.55
ln -s /usr/lib64/libicuuc.so.54 /usr/lib64/libicuuc.so.55

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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