Swift on Linux: Make very first step work Swift on Linux: Make very first step work linux linux

Swift on Linux: Make very first step work


I had the exact same problem. It turns out that I had added the ppa:ubuntu-toolchain-r/test repo in order to install g++-4.9 on my Mint distro (17.2). Once I purged the repository and restored various libraries to their original versions, swift finally worked for me.

Specifically, I had to run

sudo apt-get install ppa-purgesudo ppa-purge -d trusty ppa:ubuntu-toolchain-r/test

While cleaning up, ppa-purge was complaining that in order to resolve conflicts, it would have to remove quite a few packages it could not find in the Ubuntu Trusty repo (including really core ones like build-essential, xorg, gcc, x11-xserver-utils...), so I made a note and reinstalled these right away after the purge. Just be very careful.

I think some of the libraries overridden when installing g++ 4.9 were creating a conflict. I've verified all this on a fresh Mint install too.


This is not really an answer -- I have the same problem as OP -- but SwiftShims is actually defined the module.map file in your file listing above:

module SwiftShims {  header "CoreFoundationShims.h"  header "FoundationShims.h"  header "GlobalObjects.h"  header "HeapObject.h"  header "LibcShims.h"  header "RefCount.h"  header "RuntimeShims.h"  header "RuntimeStubs.h"  header "SwiftStddef.h"  header "SwiftStdint.h"  header "UnicodeShims.h"  export *}

https://github.com/apple/swift/blob/8d9ef80304d7b36e13619ea50e6e76f3ec9221ba/stdlib/public/SwiftShims/module.map


I repeated the same steps as you described on a brand-new Ubuntu 14.04 Azure VM and got the expected

$R0: Int = 3

Interestingly, it worked fine even without Clang or GCC! Later I installed Clang-3.5, and it worked as well.

Is it possible that they have sneaked in a new tarball with the same name? The MD5 hash of the one I got is here:

user@ubuntu1:/tmp/junk$ md5sum swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz a93f52921c491b747cad256904c8742f  swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz

Does yours match? If so, you may want to try a different installation of Ubuntu 14.04 if you have access to one.

I have also been able to successfully use swift build as instructed in https://swift.org/getting-started/#using-the-build-system . Removing the clang-3.5 package broke swift build, just as I had suspected, but REPL swift still worked as it did originally, before installing Clang for the first time. Then I installed Clang-3.4, and swift build was back in business.

Update 1/3/2016:

Using the hints from the various comments on this question, I've been able to reproduce the error on my Ubuntu 14.04 Azure VM. As an alternative solution, the problem can also be addressed by manipulating $LD_LIBRARY_PATH, see Unable to compile "hello world" program with Swift on Ubuntu 14.04.