Skip to content

[Bug] Linux: whisper.cpp fails with "error while loading shared libraries: libwhisper.so.1: cannot open shared object file" #13680

Description

@keremyavuz

*I encountered a issue while I was trying to use speech to text function in Subtitle Edit. I use EndavourOS. I solved the problem by using AI. Having resolved the issue, I also wanted to create a ticket to let the developers know the issue. Here is the explanation of AI. Thank you.

### Environment
- **OS:** Linux (Arch Linux / EndeavourOS x86_64)
- **Subtitle Edit Version:** 5.1.0 (or latest)
- **Engine:** whisper.cpp (Speech-to-Text)

### Description
When running speech-to-text via **whisper.cpp** on Linux, the process fails immediately on launch with a missing shared library error.

### Error Log
```text
Calling speech-to-text (CPP) with : /home/user/.config/Subtitle Edit/SpeechToText/Cpp/whisper-cli --language en --model "/home/user/.config/Subtitle Edit/SpeechToText/Cpp/Models/tiny.en.bin" --output-srt --print-progress  "/tmp/se-stt-xxx/sample.wav"
/home/user/.config/Subtitle Edit/SpeechToText/Cpp/whisper-cli: error while loading shared libraries: libwhisper.so.1: cannot open shared object file: No such file or directory
Speech to text (CPP) done in 00:00:00.0961585

Running ldd on whisper-cli confirms missing dependencies:

$ ldd ~/.config/Subtitle\ Edit/SpeechToText/Cpp/whisper-cli | grep "not found"
    libwhisper.so.1 => not found
    libggml.so.0 => not found

Root Cause Analysis
Missing Shared Library: The automated download/extraction for the Linux whisper.cpp bundle in ~/.config/Subtitle Edit/SpeechToText/Cpp/ contains libggml*.so files, but libwhisper.so (or libwhisper.so.1) is missing entirely from the directory.

Missing ABI Symlinks: The binary specifically links against versioned SONAMEs (libwhisper.so.1, libggml.so.0). If only unversioned .so files exist, the dynamic linker (ld.so) fails to resolve them.

Missing RPATH / $ORIGIN: The provided whisper-cli binary does not have its RPATH / RUNPATH set to $ORIGIN. As a result, Linux does not search the local executable directory for bundled .so files unless LD_LIBRARY_PATH is explicitly exported.

Workaround Applied
Building whisper.cpp from source and updating the binary's RPATH resolves the issue completely:

TARGET="$HOME/.config/Subtitle Edit/SpeechToText/Cpp"

# Copy built shared libraries
cp -f build/bin/*.so* "$TARGET/"

# Create version symlinks
cd "$TARGET"
ln -sf libwhisper.so libwhisper.so.1
ln -sf libggml.so libggml.so.0

# Set RPATH so whisper-cli looks in its own folder for .so files
patchelf --set-rpath '$ORIGIN' whisper-cli

Suggested Fix
To make whisper.cpp work out of the box on Linux:

Ensure the downloaded zip/archive includes libwhisper.so alongside the libggml files (including the versioned symlink libwhisper.so.1).

Either:

Build the distributed whisper-cli binary with -DCMAKE_INSTALL_RPATH='$ORIGIN' (or patch it with patchelf --set-rpath '$ORIGIN'), OR

In Subtitle Edit's process execution code, prepend the directory to LD_LIBRARY_PATH when spawning whisper-cli:
process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] = cppFolder + ":" + Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions