Unable to load shared library 'opencl' or one of its dependencies

I am getting these exceptions, while running the project. Could you tell me how to solve the problem?

Inner exception: Unable to load shared library 'opencl' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.3/opencl.so: cannot open shared object file: No such file or directory
/home/katalan/dev/GraphBLAS-sharp/tests/GraphBLAS-sharp.Tests/bin/Debug/net7.0/opencl.so: cannot open shared object file: No such file or directory
opencl.so: cannot open shared object file: Too many levels of symbolic links
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.3/libopencl.so: cannot open shared object file: No such file or directory
/home/katalan/dev/GraphBLAS-sharp/tests/GraphBLAS-sharp.Tests/bin/Debug/net7.0/libopencl.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.3/opencl: cannot open shared object file: No such file or directory
/home/katalan/dev/GraphBLAS-sharp/tests/GraphBLAS-sharp.Tests/bin/Debug/net7.0/opencl: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.3/libopencl: cannot open shared object file: No such file or directory
/home/katalan/dev/GraphBLAS-sharp/tests/GraphBLAS-sharp.Tests/bin/Debug/net7.0/libopencl: cannot open shared object file: No such file or directory

With the risk of stating the obvious

pamac search opencl --no-aur
lib32-ocl-icd                                                               2.3.1-1           multilib 
    OpenCL ICD Bindings (32-bit)
intel-oneapi-basekit                                                        2023.1.0.46401-1  community 
    Intel oneAPI Base Toolkit for Linux
intel-compute-runtime                                                       23.09.25812.14-1  community 
    Intel(R) Graphics Compute Runtime for oneAPI Level Zero and OpenCL(TM)
    Driver
ocl-icd                                                         [Installed] 2.3.1-1           extra 
    OpenCL ICD Bindings
rocm-opencl-sdk                                                             5.4.3-2           community 
    Develop OpenCL-based applications for AMD platforms
rocm-opencl-runtime                                                         5.4.3-1           community 
    OpenCL implementation for AMD
python-pyopencl                                                             1:2022.2.3-2      community 
    A complete, object-oriented language binding of OpenCL to Python
pyopencl-headers                                                            1:2022.2.3-2      community 
    A complete, object-oriented language binding of OpenCL to Python
lib32-opencl-nvidia-470xx                                                   470.182.03-1      multilib 
    OpenCL implemention for NVIDIA (32-bit)
lib32-opencl-nvidia-390xx                                                   390.157-4         multilib 
    OpenCL implemention for NVIDIA (32-bit)
lib32-opencl-mesa                                                           23.0.4-1          multilib 
    OpenCL support for AMD/ATI Radeon mesa drivers (32-bit)
intel-opencl-clang                                                          15.0.0-1          community 
    Wrapper library around clang that can compile OpenCL C kernels to
    SPIR-V modules
lib32-opencl-nvidia                                             [Installed] 530.41.03-1       multilib 
    OpenCL implemention for NVIDIA (32-bit)
opencl-nvidia-470xx                                                         470.182.03-2      extra 
    OpenCL implemention for NVIDIA
opencl-nvidia-390xx                                                         390.157-6         extra 
    OpenCL implemention for NVIDIA
opencl-mesa                                                                 23.0.4-1          extra 
    OpenCL support with clover and rusticl for mesa drivers
opencl-clhpp                                                                2.0.16-1          extra 
    OpenCL C++ header files
opencl-nvidia                                                   [Installed] 530.41.03-4       extra 
    OpenCL implemention for NVIDIA
opencl-headers                                                  [Installed] 2:2022.09.30-1    extra 
    OpenCL (Open Computing Language) header files

Then you are missing something else.

There is 7 dotnet packages.

It is quite possible that - even though it is available from the repo - there is a mismatch as dotnet packages are targeted Ubuntu, Redhat, Suse etc. but not Manjaro or Arch.

I use a custom build script to keep my dotnet current.

You cannot build it using pamac - you need to do it the arch way.

git clone https://aur.archlinux.org/dotnet-core-bin
cd dotnet-core-bin
makepkg -iscC

Oh, didn’t know. Thank you. But, unfortunately, it didn’t solve the problem: same exception.
But at first i haven’t noticed the message at the beginning:

System.DllNotFoundException: Unable to load shared library '/usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.7//usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0: cannot open shared object file: No such file or directory

Actually, i have no /usr/lib/x86_64-linux-gnu/ directory at all.

Looks like an error in the path - note the doubled // before usr/

Is it? That’s quite a strange path. Why /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 should be in the /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.7/ ? Can it be just incorrect console output?

I have no idea.

What I do know is that /usr/lib/libOpenCL.so.1.0.0 is a valid library - at least on my system.

So what ever you are doing the process looks in the wrong location - whether this is a product of assumptions made by dotnet or by the packager or your source or a combination - I have no idea.

1 Like

The problem was that the library i used could not find the opencl lib in its default place. So i had to set environment variable to specify the path to the library object file. That solved my problem. Thank you for helping!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.