Running swift for the first time (error message: lldb: error while loading shared libraries)

Hi!

Today is my first day using Swift.
I downloaded it from swift.org.
When I try to run the command "swift", the term returns this error message:

/home/ddraig/Swift/usr/bin/lldb: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

But Python3 is installed...
What can I do now?

Thank you for any help.

What OS and Swift version are you using? On linux, you might need to update the Python version, or if you'd rather just use what you have, you could add a symbolic link so lldb uses that: sudo ln -s /usr/lib64/libpython3.10.so.1.0 /usr/lib64/libpython3.8.so.1.0. I just did the latter when running the Swift debugger from the Swift 5.5.2 toolchain on Fedora Core 35 without a problem.

Btw, the reason running swift calls lldb is that you're starting the REPL, which uses lldb, but you're more likely going to want to use the package manager to build packages instead.

Hello dear user Buttaface!

I apologize for the delay in answering you.
Thank you so much for your help.
I had to reinstall Ubuntu because I found out, using the python3 --version command, that my version was 3.9 , but swift requires 3.8 (I was using the Ubuntu 21, and now I am using ubuntu 20.4).
I know Fedora, it is a awesome distro, I used it a few years ago (sometimes I think I used every distro available lol)
I will keep all your tips for future reference, you were very kind.
A wonderful weekend for you!

Alexandre.

I am also seeing this issue on Ubuntu 21.10, which doesn't provide Python 3.8, but rather 3.9 and 3.10.

I was unable to make a downgrade, I had to reinstall Ubuntu, installing the version 20.
After that, everything worked fine: now I can use swift!
By the way, in another thread, an user told me that there is a SwiftUI-compatible framework for building browser apps in Linux, called Tokamak U. I. :

https://github.com/TokamakUI/Tokamak

Happy coding.

Why is Swift linking to libraries that it doesn't provide?
Can Swift be compile so that it's self contained?

I'm trying to Run Swift for Ubuntu 20.04 on Ubuntu 22.04

Why is Swift linking to libraries that it doesn't provide?

It is only the compiler linking to libpython.

Can Swift be compile so that it's self contained?

If you mean the compiler, maybe, but most other compilers depend on system libraries too.

If you mean the runtime, I only count 13 system libraries like libc.so.6 required by the 23 Swift-related libraries in usr/lib/swift/linux/ provided by the latest May 27 prebuilt trunk snapshot of the toolchain.

I'm trying to Run Swift for Ubuntu 20.04 on Ubuntu 22.04

I think that should work because of backward compatibility, or after adding possibly needed links like I suggested.

For our own C++ projects we build a Debian docker container with our own GCC and glibc to achieve portable application. This setup was created years ago and so far has worked well. I wonder the same can be achieved with Swift?

You may have to add clang, libc++, and the LLVM libraries to your docker image. These are used by the swift compiler. They may get added if/when you build the Swift environment. Not sure if that is going to add conflicts in your system architecture.

Hello all
Here is the solution

  1. sudo find / -name libpython3.8.so.1.0
  2. sudo cp (Result path) /usr/lib