fix in linux build: requirelibonnxruntime.so.1.23.2instead libonnxruntime.so.1 #24
fix in linux build: requirelibonnxruntime.so.1.23.2instead libonnxruntime.so.1 #24NaGeLBailey wants to merge 1 commit intoxurei:mainfrom
Conversation
|
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? Also : if you do use Discord, could you reach to me there? My handle is |
|
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 ❯ 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:
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.
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. 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. |
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.2Depending 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.2and will load the correct version even ifonnxruntime.so.1was loaded with a different version.this modification also allows to work in Flatpak environment!
Oh the envrioment i tested is:
CachyOS(arch)