Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions .github/workflows/test-rust-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ concurrency:

jobs:
test-rust-package:
name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-15-intel, ubuntu-22.04-arm]
os: [ubuntu-latest, macos-latest, macos-15-intel, ubuntu-22.04-arm, windows-latest]

env:
# Placeholder, will be overwritten per OS
Expand All @@ -32,6 +33,22 @@ jobs:
with:
toolchain: stable

- name: Set up MSVC
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1

- name: Select MSVC linker
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$linker = Join-Path $env:VCToolsInstallDir 'bin\HostX64\x64\link.exe'
if (-not (Test-Path $linker)) {
throw "MSVC linker not found: $linker"
}
"CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=$linker" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Using linker: $linker"
& where.exe link

# Download prebuilt libraries depending on OS
- name: Download prebuilt Sherpa-ONNX libraries
shell: bash
Expand All @@ -46,6 +63,8 @@ jobs:
d=sherpa-onnx-v$SHERPA_ONNX_VERSION-linux-x64-shared
elif [[ "${{ matrix.os }}" == "ubuntu-22.04-arm" ]]; then
d=sherpa-onnx-v$SHERPA_ONNX_VERSION-linux-aarch64-shared-cpu
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
d=sherpa-onnx-v$SHERPA_ONNX_VERSION-win-x64-shared-MT-Release
else
echo "Unknown ${{ matrix.os }}"
exit 1
Expand All @@ -60,7 +79,16 @@ jobs:

# Export environment variables for this step
echo "SHERPA_ONNX_LIB_DIR=$PWD/$d/lib" >> $GITHUB_ENV
echo "RUSTFLAGS=-C link-arg=-Wl,-rpath,$PWD/$d/lib" >> $GITHUB_ENV
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
if [[ -d "$PWD/$d/bin" ]]; then
echo "$PWD/$d/bin" >> $GITHUB_PATH
ls -lh $d/bin
fi
echo "$PWD/$d/lib" >> $GITHUB_PATH
echo "RUSTFLAGS=" >> $GITHUB_ENV
else
echo "RUSTFLAGS=-C link-arg=-Wl,-rpath,$PWD/$d/lib" >> $GITHUB_ENV
fi

- name: Show libs
shell: bash
Expand All @@ -69,8 +97,17 @@ jobs:
ls -lh $SHERPA_ONNX_LIB_DIR

echo "RUSTFLAGS: $RUSTFLAGS"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: $CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER"
fi

- name: Run test
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
export PATH="$SHERPA_ONNX_LIB_DIR:$PATH"
mkdir -p rust-api-examples/target/debug/examples
cp -v "$SHERPA_ONNX_LIB_DIR"/*.dll rust-api-examples/target/debug/examples/

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp -v "$SHERPA_ONNX_LIB_DIR"/*.dll ... will fail the step when no DLLs exist in $SHERPA_ONNX_LIB_DIR (very common if DLLs live under bin/ in the archive). Guard the copy (e.g., check for matches / enable nullglob) and/or copy from the directory that actually contains the DLLs (often $PWD/$d/bin) to avoid spurious CI failures.

Suggested change
cp -v "$SHERPA_ONNX_LIB_DIR"/*.dll rust-api-examples/target/debug/examples/
if compgen -G "$SHERPA_ONNX_LIB_DIR"/*.dll > /dev/null; then
cp -v "$SHERPA_ONNX_LIB_DIR"/*.dll rust-api-examples/target/debug/examples/
else
echo "No DLLs found in $SHERPA_ONNX_LIB_DIR, skipping copy."
fi

Copilot uses AI. Check for mistakes.
ls -lh rust-api-examples/target/debug/examples/
fi
./.github/scripts/test-rust.sh
8 changes: 8 additions & 0 deletions .github/workflows/windows-arm64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ jobs:
cp -a build/install/lib $dst/
cp -a build/install/include $dst/

if [[ $shared_lib == "ON" && -f build/install/lib/onnxruntime.lib ]]; then
cp -v build/install/lib/onnxruntime.lib $dst/lib/
fi

rm -rf $dst/lib/pkgconfig
rm -f $dst/lib/cargs.dll $dst/lib/cargs.lib $dst/lib/cargs.h
rm -f $dst/include/cargs.h

ls -lh $dst/bin/
echo "---"
ls -lh $dst/lib/
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/windows-x64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ jobs:
cp -a build/install/lib $dst/
cp -a build/install/include $dst/

if [[ $shared_lib == "ON" && -f build/install/lib/onnxruntime.lib ]]; then
cp -v build/install/lib/onnxruntime.lib $dst/lib/
fi

rm -rf $dst/lib/pkgconfig
rm -f $dst/lib/cargs.dll $dst/lib/cargs.lib $dst/lib/cargs.h
rm -f $dst/include/cargs.h

ls -lh $dst/bin/
echo "---"
ls -lh $dst/lib/
Expand Down Expand Up @@ -244,7 +252,7 @@ jobs:
file: sherpa-onnx-*-win-x64*.tar.bz2
repo_name: k2-fsa/sherpa-onnx
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
tag: v1.12.28
tag: v1.12.31

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the release tag increases the risk of uploading artifacts to the wrong GitHub Release when versions change. Prefer using the tag from the workflow context (e.g., ${{ github.ref_name }}) so the workflow automatically targets the pushed tag.

Suggested change
tag: v1.12.31
tag: ${{ github.ref_name }}

Copilot uses AI. Check for mistakes.

- name: Release pre-compiled binaries and libs for Windows x64
if: github.repository_owner == 'k2-fsa'&& github.event_name == 'push' && contains(github.ref, 'refs/tags/')
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/windows-x86.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ jobs:
cp -a build/install/lib $dst/
cp -a build/install/include $dst/

if [[ $shared_lib == "ON" && -f build/install/lib/onnxruntime.lib ]]; then
cp -v build/install/lib/onnxruntime.lib $dst/lib/
fi

rm -rf $dst/lib/pkgconfig
rm -f $dst/lib/cargs.dll $dst/lib/cargs.lib $dst/lib/cargs.h
rm -f $dst/include/cargs.h

ls -lh $dst/bin/
echo "---"
ls -lh $dst/lib/
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

if(NOT WIN32)
if(UNIX)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Expand All @@ -138,7 +138,7 @@ else()
set(SHERPA_ONNX_RPATH_ORIGIN "@loader_path")
endif()

if(NOT WIN32)
if(UNIX)
set(CMAKE_INSTALL_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
set(CMAKE_BUILD_RPATH ${SHERPA_ONNX_RPATH_ORIGIN})
endif()
Expand Down
1 change: 1 addition & 0 deletions cmake/onnxruntime-win-arm64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")

install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib)
1 change: 1 addition & 0 deletions cmake/onnxruntime-win-x64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")

install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib)

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This install(FILES ...) will hard-fail at install/package time if ${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib doesn’t exist for a given onnxruntime layout/version. To make packaging resilient, guard it with an if(EXISTS ...) (and optionally emit a clear message(FATAL_ERROR ...) only when the build truly requires it). The same issue applies to the analogous x86/arm64 CMake files.

Suggested change
install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib)
if(EXISTS "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib")
install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib)
else()
message(WARNING "onnxruntime import library not found at '${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib'; it will not be installed.")
endif()

Copilot uses AI. Check for mistakes.
1 change: 1 addition & 0 deletions cmake/onnxruntime-win-x86.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}")

install(FILES ${onnxruntime_lib_files} DESTINATION lib)
install(FILES ${onnxruntime_lib_files} DESTINATION bin)
install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib)
1 change: 1 addition & 0 deletions new-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ sed -i.bak "$replace_str" ./android/SherpaOnnxAar/README.md
sed -i.bak "$replace_str" ./rust-api-examples/Cargo.toml
sed -i.bak "$replace_str" ./sherpa-onnx/rust/sherpa-onnx-sys/Cargo.toml
sed -i.bak "$replace_str" ./sherpa-onnx/rust/sherpa-onnx/Cargo.toml
sed -i.bak "$replace_str" ./sherpa-onnx/rust/sherpa-onnx/src/lib.rs
sed -i.bak "$replace_str" ./rust-api-examples/README.md

find android -name build.gradle -type f -exec sed -i.bak "s/sherpa-onnx:v$old_version/sherpa-onnx:v$new_version/g" {} \;
Expand Down
101 changes: 92 additions & 9 deletions rust-api-examples/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,88 @@
# Introduction

This folder uses Rust API maintained by us.
This folder contains examples that use the `sherpa-onnx` Rust crate maintained in
this repository.

## Setup library path
## Setup

### Method 1 (Build from source, support only shared libs right now)
The Rust crate needs to find the sherpa-onnx shared libraries at build time, and
your operating system needs to find them again at run time.

There are two common ways to do that:

- Method 1: Build sherpa-onnx from source and use the generated shared libraries
- Method 2: Download a prebuilt sherpa-onnx shared-library package from GitHub releases

### Method 1: Build from source

Build and install sherpa-onnx first. After that, point `SHERPA_ONNX_LIB_DIR` to
the generated `lib` directory.

#### Linux

```bash
export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/build/install/lib
export RUSTFLAGS="-C link-arg=-Wl,-rpath,$SHERPA_ONNX_LIB_DIR"
```

#### macOS

```bash
export SHERPA_ONNX_LIB_DIR=/Users/fangjun/open-source/sherpa-onnx/build/install/lib
export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/build/install/lib
export RUSTFLAGS="-C link-arg=-Wl,-rpath,$SHERPA_ONNX_LIB_DIR"
```

### Method 2 (Download pre-built libs)
#### Windows

```bash
export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/build/install/lib
export PATH="$SHERPA_ONNX_LIB_DIR:$PATH"
```

If Windows still reports that it cannot find a DLL, or if it loads a wrong
`onnxruntime.dll`, copy the DLL files from `%SHERPA_ONNX_LIB_DIR%` to the same

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section mixes Windows cmd.exe syntax (%SHERPA_ONNX_LIB_DIR%) with surrounding Git-Bash/MSYS-style export ... commands. To prevent users from copying the wrong syntax, either (a) change %SHERPA_ONNX_LIB_DIR% to $SHERPA_ONNX_LIB_DIR to match the shown shell, or (b) explicitly provide distinct snippets for PowerShell / cmd.exe vs Git Bash.

Suggested change
`onnxruntime.dll`, copy the DLL files from `%SHERPA_ONNX_LIB_DIR%` to the same
`onnxruntime.dll`, copy the DLL files from `$SHERPA_ONNX_LIB_DIR` to the same

Copilot uses AI. Check for mistakes.
directory as the generated example executable, e.g.
`rust-api-examples/target/debug/examples/`.

### Method 2: Download prebuilt shared libraries

This is the easiest method for most users.

1. Go to [GitHub releases](https://github.com/k2-fsa/sherpa-onnx/releases)
2. Download the archive that matches your operating system
3. Extract it anywhere you like
4. Set `SHERPA_ONNX_LIB_DIR` to the extracted `lib` directory
5. On Linux/macOS, also set `RUSTFLAGS` so the executable can find the shared libraries
6. On Windows, add the same `lib` directory to `PATH`

Use the latest release in practice. We use `v1.12.31` below only as an example.

#### Which archive should I download?

| OS | Archive example | Download link |
|----|-----------------|---------------|
| Linux x86_64 | `sherpa-onnx-v1.12.31-linux-x64-shared.tar.bz2` | [Download](https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-linux-x64-shared.tar.bz2) |
| Linux aarch64 | `sherpa-onnx-v1.12.31-linux-aarch64-shared-cpu.tar.bz2` | [Download](https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-linux-aarch64-shared-cpu.tar.bz2) |
| macOS | `sherpa-onnx-v1.12.31-osx-universal2-shared.tar.bz2` | [Download](https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-osx-universal2-shared.tar.bz2) |
| Windows x64 | `sherpa-onnx-v1.12.31-win-x64-shared-MT-Release.tar.bz2` | [Download](https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-win-x64-shared-MT-Release.tar.bz2) |

#### Linux

```bash
# You can choose any directory you like
cd $HOME/Downloads

# We use version v1.12.31 below as an example.
# Please always use the latest version from
# https://github.com/k2-fsa/sherpa-onnx/releases
wget https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-linux-x64-shared.tar.bz2
tar xvf sherpa-onnx-v1.12.31-linux-x64-shared.tar.bz2
rm sherpa-onnx-v1.12.31-linux-x64-shared.tar.bz2

export SHERPA_ONNX_LIB_DIR=$HOME/Downloads/sherpa-onnx-v1.12.31-linux-x64-shared/lib
export RUSTFLAGS="-C link-arg=-Wl,-rpath,$SHERPA_ONNX_LIB_DIR"
```

#### macOS

```bash
cd $HOME/Downloads

wget https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-osx-universal2-shared.tar.bz2
tar xvf sherpa-onnx-v1.12.31-osx-universal2-shared.tar.bz2
Expand All @@ -29,6 +92,26 @@ export SHERPA_ONNX_LIB_DIR=$HOME/Downloads/sherpa-onnx-v1.12.31-osx-universal2-s
export RUSTFLAGS="-C link-arg=-Wl,-rpath,$SHERPA_ONNX_LIB_DIR"
```

#### Windows

```bash
cd /c/Users/$USERNAME/Downloads

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.12.31/sherpa-onnx-v1.12.31-win-x64-shared-MT-Release.tar.bz2
tar xvf sherpa-onnx-v1.12.31-win-x64-shared-MT-Release.tar.bz2
rm sherpa-onnx-v1.12.31-win-x64-shared-MT-Release.tar.bz2

export SHERPA_ONNX_LIB_DIR=/c/Users/$USERNAME/Downloads/sherpa-onnx-v1.12.31-win-x64-shared-MT-Release/lib
export PATH="$SHERPA_ONNX_LIB_DIR:$PATH"
```

In most cases, updating `PATH` is enough on Windows. If an example still loads
the wrong `onnxruntime.dll`, copy the DLL files from
`$SHERPA_ONNX_LIB_DIR` to `target/debug/examples/` and run the example again.

After setting the environment variables above, you can run the examples in this
directory with `cargo run --example ...` or use the helper scripts below.

## Examples

| # | Example | Description |
Expand Down
2 changes: 1 addition & 1 deletion rust-api-examples/run-zipvoice-tts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -ex

if [ ! -f ./sherpa-onnx-zipvoice-distill-int8-zh-en-emilia/encoder.int8.onnx ]; then
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
tar xvf sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
tar xf sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
rm sherpa-onnx-zipvoice-distill-int8-zh-en-emilia.tar.bz2
fi

Expand Down
14 changes: 7 additions & 7 deletions sherpa-onnx/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ if(SHERPA_ONNX_ENABLE_BINARY)
target_link_libraries(${exe} sherpa-onnx-core)
endforeach()

if(NOT WIN32)
if(UNIX)
foreach(exe IN LISTS main_exes)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")
Expand Down Expand Up @@ -597,7 +597,7 @@ if(SHERPA_ONNX_HAS_ALSA AND SHERPA_ONNX_ENABLE_BINARY)
endif()
endforeach()

if(NOT WIN32)
if(UNIX)
foreach(exe IN LISTS exes)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")
Expand Down Expand Up @@ -702,7 +702,7 @@ if(SHERPA_ONNX_ENABLE_PORTAUDIO AND SHERPA_ONNX_ENABLE_BINARY)
target_link_libraries(${exe} portaudio_static sherpa-onnx-core)
endforeach()

if(NOT WIN32)
if(UNIX)
foreach(exe IN LISTS exes)
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
target_link_libraries(${exe} "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")
Expand Down Expand Up @@ -743,7 +743,7 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
)
target_link_libraries(sherpa-onnx-online-websocket-client sherpa-onnx-core)

if(NOT WIN32)
if(UNIX)
target_compile_options(sherpa-onnx-online-websocket-server PRIVATE -Wno-deprecated-declarations)

target_compile_options(sherpa-onnx-online-websocket-client PRIVATE -Wno-deprecated-declarations)
Expand All @@ -756,11 +756,11 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
)
target_link_libraries(sherpa-onnx-offline-websocket-server sherpa-onnx-core)

if(NOT WIN32)
if(UNIX)
target_compile_options(sherpa-onnx-offline-websocket-server PRIVATE -Wno-deprecated-declarations)
endif()

if(NOT WIN32)
if(UNIX)
target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")

Expand All @@ -770,7 +770,7 @@ if(SHERPA_ONNX_ENABLE_WEBSOCKET AND SHERPA_ONNX_ENABLE_BINARY)
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib")
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../../../sherpa_onnx/lib")

if(SHERPA_ONNX_ENABLE_PYTHON AND NOT WIN32)
if(SHERPA_ONNX_ENABLE_PYTHON)
target_link_libraries(sherpa-onnx-online-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-online-websocket-client "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
target_link_libraries(sherpa-onnx-offline-websocket-server "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/../lib/python${PYTHON_VERSION}/site-packages/sherpa_onnx/lib")
Expand Down
2 changes: 1 addition & 1 deletion sherpa-onnx/python/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ if(APPLE)
endif()
endif()

if(NOT WIN32)
if(UNIX)
target_link_libraries(_sherpa_onnx PRIVATE "-Wl,-rpath,${SHERPA_ONNX_RPATH_ORIGIN}/sherpa_onnx/lib")
endif()

Expand Down
1 change: 1 addition & 0 deletions sherpa-onnx/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
notes.md
target
Cargo.lock
3 changes: 2 additions & 1 deletion sherpa-onnx/rust/sherpa-onnx-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ fn main() {
}
}

// Link the dynamic libraries regardless (cargo will fail later if not found)
// Always link against the public sherpa-onnx C API import library.

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“import library” is Windows-specific terminology; on Linux/macOS this is a shared library (.so/.dylib). Since this build script runs cross-platform, consider rewording to “shared library” (or “link library”) to stay accurate on all targets.

Suggested change
// Always link against the public sherpa-onnx C API import library.
// Always link against the public sherpa-onnx C API shared library.

Copilot uses AI. Check for mistakes.
println!("cargo:rustc-link-lib=dylib=sherpa-onnx-c-api");

println!("cargo:rustc-link-lib=dylib=onnxruntime");

// Rebuild if the env variable changes
Expand Down
Loading
Loading