Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(stt): make the Linux whisper helper relocatable

Etienne Lescot6ffc6b507fcb
diff --git a/electron/native/whisper-stt/CMakeLists.txt b/electron/native/whisper-stt/CMakeLists.txt
index 5b413924f..8263770ee 100644
--- a/electron/native/whisper-stt/CMakeLists.txt
+++ b/electron/native/whisper-stt/CMakeLists.txt
@@ -97,6 +97,21 @@ set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_ZLIB_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_BROTLI_IF_AVAILABLE OFF CACHE BOOL "" FORCE)
+# ponytail: on Linux, ggml/whisper build as separate shared objects and CMake
+# bakes the absolute build-tree `bin/` path into each RUNPATH. The build script
+# then copies the binary and its libs side by side into
+# `electron/native/bin/linux-x64/`, where that absolute path is meaningless the
+# moment the build cache is wiped or the app is packaged on another machine.
+# Resolve relative to the executable instead. `$ORIGIN/bin` keeps the binary in
+# the build tree runnable too (it lands at the build root while the libs go to
+# `bin/`). Set before MakeAvailable so the whisper/ggml targets inherit it.
+# macOS is left alone: it needs @loader_path rather than $ORIGIN and is not
+# testable from here.
+if(UNIX AND NOT APPLE)
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
+ set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/bin")
+endif()
+
FetchContent_MakeAvailable(whisper httplib json)
add_executable(whisper-stt-server src/main.cpp)