Skip to content

Commit aef4da2

Browse files
committed
Fix ORT not found in AppImage
1 parent 76f96d5 commit aef4da2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/ai/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ if(UNIX AND NOT APPLE)
4040
# before darktable has a chance to check the AI-enabled preference.
4141
# Also suppresses harmless "already registered" ONNX schema warnings
4242
# from system packages that link against libonnx.
43+
# Use just the filename (not the full build-tree path) so g_module_open
44+
# resolves it via LD_LIBRARY_PATH / system linker search. This is required
45+
# for AppImage where the build-tree path does not exist at runtime.
46+
get_filename_component(_ORT_LIB_NAME "${ONNXRuntime_LIBRARIES}" NAME)
4347
target_compile_definitions(darktable_ai PRIVATE
4448
ORT_LAZY_LOAD=1
45-
ORT_LIBRARY_PATH="${ONNXRuntime_LIBRARIES}")
49+
ORT_LIBRARY_PATH="${_ORT_LIB_NAME}")
4650
target_include_directories(darktable_ai PRIVATE ${ONNXRuntime_INCLUDE_DIRS})
4751
else()
4852
target_link_libraries(darktable_ai PUBLIC onnxruntime::onnxruntime)

tools/appimage-build-script.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ cp -a /usr/lib/$ARCH-linux-gnu/libgphoto2_port/* ../AppDir/usr/lib/libgphoto2_po
7070
mkdir -p ../AppDir/usr/lib/gio
7171
cp -a /usr/lib/$ARCH-linux-gnu/gio/* ../AppDir/usr/lib/gio
7272

73+
# Include ONNX Runtime library. ORT is loaded via dlopen (ORT_LAZY_LOAD) so
74+
# linuxdeploy can't detect it automatically. Copy from the build tree.
75+
ORT_LIB_DIR=$(cmake -LA -N ../build 2>/dev/null | grep ONNXRuntime_LIB_DIR:PATH | cut -d= -f2)
76+
if [ -d "$ORT_LIB_DIR" ]; then
77+
cp -a "$ORT_LIB_DIR"/libonnxruntime*.so* ../AppDir/usr/lib/
78+
echo "Bundled ONNX Runtime from $ORT_LIB_DIR"
79+
fi
80+
7381
# Since linuxdeploy is itself an AppImage, we don't rely on it being installed
7482
# on the build system, but download it every time we run this script. If that
7583
# doesn't suit you (for example, you want to build an AppImage without an

0 commit comments

Comments
 (0)