Skip to content

fix in linux build: requirelibonnxruntime.so.1.23.2instead libonnxruntime.so.1 #24

Open
NaGeLBailey wants to merge 1 commit intoxurei:mainfrom
NaGeLBailey:main
Open

fix in linux build: requirelibonnxruntime.so.1.23.2instead libonnxruntime.so.1 #24
NaGeLBailey wants to merge 1 commit intoxurei:mainfrom
NaGeLBailey:main

Conversation

@NaGeLBailey
Copy link
Copy Markdown

@NaGeLBailey NaGeLBailey commented Apr 15, 2026

I was trying to use this OBS plugin in Linux Environment and it works wonderfully!

issue arise when i try to use with other Plugins that uses onnxruntime as welll like LocalVocal or BackgroundRemoval.
Both of use different version of said runtime and All of them ask for onnxruntime.so.1, even tho what they want is 1.22 or in this plugin's case 1.23.2

Depending which plugin loads first that version of onnxruntime.so.1 will be loaded for everyone else as well, and this creates conflict.

This merge request changes the linux building so that when the build is done at the end patchelf utility make t so that it requires the exact version aka onnxruntime.so.1.23.2 and will load the correct version even if onnxruntime.so.1 was loaded with a different version.

this modification also allows to work in Flatpak environment!

Oh the envrioment i tested is:
CachyOS(arch)

@xurei
Copy link
Copy Markdown
Owner

xurei commented Apr 17, 2026

Oh great ! I had the same issue myself and didn't have the knowledge to fix it ❤️

By any chance, do you know if this method would work on a Windows environment?
I crafted some hacky way to do basically the same thing, but I wonder if it's possible to put it in the Makefile in the same way 🤔

Also : if you do use Discord, could you reach to me there? My handle is xurei42

@NaGeLBailey
Copy link
Copy Markdown
Author

NaGeLBailey commented Apr 17, 2026

Yeah even this method is kinda hacky, but I can explain why this hack is needed to point at the exact version number.

When we get the binary of onnxruntime the filename can be whatever it want, but for cmake and linking libraries there is only one important part: The internal soname

❯ readelf -d libonnxruntime.so.1.23.2 | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [libonnxruntime.so.1]

The library calls itself libonnxruntime.so.1 so that's what cmake linker will use and add to shadertastic.so as needed library.

❯ readelf -d shadertastic.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libobs-frontend-api.so.30]
 0x0000000000000001 (NEEDED)             Shared library: [libQt6Widgets.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libonnxruntime.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libobs.so.30]
 0x0000000000000001 (NEEDED)             Shared library: [libQt6Gui.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libGLX.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libOpenGL.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libQt6Core.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

So what patchelf does is replace the Needed So name

patchelf --replace-needed libonnxruntime.so.1 libonnxruntime.so.1.23.2 shadertastic.so

readelf -d shadertastic.so | grep NEEDED
0x0000000000000001 (NEEDED)             Shared library: [libobs-frontend-api.so.30]
0x0000000000000001 (NEEDED)             Shared library: [libQt6Widgets.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libonnxruntime.so.1.23.2]
0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libobs.so.30]
0x0000000000000001 (NEEDED)             Shared library: [libQt6Gui.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libGLX.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libOpenGL.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libQt6Core.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

thus when it request the is for libonnxruntime it gets the correct version.

Now what i found there might be two other methods:

  1. Building onnxruntime ourself and rename the soname into the vresion name
set_target_properties(libonnxruntime PROPERTIES 
    VERSION 1.23.4
    SOVERSION 1.23.4 # This forces the SONAME to match the full version
)

and after this when we build shadertastic against this, the correct soname will be used.
I didnt use this cuz building the library would be out of scope...

  1. "CmakeLinker Flag Hack"

This is basically telling cmake linker to not use the iternal soname but use the filename.

target_link_libraries(my_project PRIVATE "-l:libonnxruntime.so.1.23.2")

this might be the thing you are looking for even in windows, but the reason I didn't use this methd, cuz i could not make it work.

maybe you can with more knowlege about this projects.
https://cmake.org/cmake/help/latest/command/target_link_libraries.html

And of course the Third method the elfpatch which actually worked....

If you can do any other method, the elfpatcher would not be needed, and maybe would solve your windows problem as well.

Also as disclaimer i did use Gemini AI to at least orient myself of what can be done

Also as a disclaimer I did use Gemini AI to orient myself and later get these methods, where the elf patcher worked best. I did rad the provided code and tested it as well.

Also added you on discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants