0

I have installed ocl-icd-opencl-dev and I try to run a simple OpenCL app, called vadd:

$ ./vadd
./vadd: error while loading shared libraries: libOpenCL.so.1: cannot open shared object file: No such file or directory

I have followed this, and the output looks as follows (I 've kept only the interesting part):

$ strace -f -v -s150 ./vadd 2>&1 | fgrep libOpenCL.so.1
...
open("/usr/lib/x86_64-linux-gnu/libOpenCL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
...

Well...

$ ls -la /usr/lib/x86_64-linux-gnu/ | grep libOpenCL
lrwxrwxrwx   1 root root       18 Dec 18  2015 libOpenCL.so.1 -> libOpenCL.so.1.0.0

What am I missing here? Is it a problem that libOpenCL.so.1 is a symlink?

1

It's not the issue that libOpenCL.so.1 is a symlink, but that it is a broken symlink.

$ ls -la /usr/lib/x86_64-linux-gnu/ | grep libOpenCL
lrwxrwxrwx   1 root root       18 Dec 18  2015 libOpenCL.so.1 -> libOpenCL.so.1.0.0

The above output shows only the symlink which points to the "real" file libOpenCL.so.1.0.0. However, that file should exist in the same directory, but it is not available. That is why the strace output reports ENOENT when trying to read the file.

  • Hmm... Do you have any idea how to fix this? Purging and reinstalling ocl-icd-opencl-dev doesn't seem to work... – Zehanort Aug 15 at 22:25
  • You don't state what distribution you are running. Assuming Ubuntu, make sure you run apt-get purge ocl-icd-opencl-dev; apt-get autoremove; apt-get install ocl-icd-opencl-dev. That said, if you are running Ubuntu, you shouldn't have seen this problem in the first place. You might want to look at the package contents for ocl-icd-opencl-dev, as well as the dependencies, there should be a dependency on a library package which should provide the libOpenCL.so.1.0.0 file. – QIS Aug 15 at 22:31
1

I managed to solve this, so I am posting what I did in case anybody falls in the same pit.

First of all, I did have a broken symlink here:

$ ls -la /usr/lib/x86_64-linux-gnu/ | grep libOpenCL
lrwxrwxrwx   1 root root       18 Dec 18  2015 libOpenCL.so.1 -> libOpenCL.so.1.0.0

I had OpenCL installed via the Intel SDK for OpenCL Applications, and I had messed things up with the installation a little.

What I found after some digging is that the Intel SDK installation installs the OpenCL shared libraries -having in mind changes in year and versions- in /opt/intel/system_studio_2019/opencl_compilers_and_libraries_18.1.0.013/linux/compiler/lib/intel64_lin/. For my system (Linux Mint), this is the default location (the only thing you can change during the installation is /opt/intel/). In fact, it looks something like this:

$ ls -l /opt/intel/system_studio_2019/opencl_compilers_and_libraries_18.1.0.013/linux/compiler/lib/intel64_lin/ | grep libOpenCL
lrwxrwxrwx 1 root root        16 Aug 16 04:35 libOpenCL.so -> ./libOpenCL.so.1
lrwxrwxrwx 1 root root        18 Aug 16 04:35 libOpenCL.so.1 -> ./libOpenCL.so.2.0
-rwxr-xr-x 1 root root     48216 Sep 21  2018 libOpenCL.so.2.0

This means that the only "actual" file is libOpenCL.so.2.0 and there is a train of symlinks: libOpenCL.so -> libOpenCL.so.1 -> libOpenCL.so.2.0.

Furthermore, I found out that there is a number of symlinks in /etc/alternatives/, that look quite OK (basically, what I understood is that they resolve the number at the end of the library name and serve as a middleman in case something changes at the actual libraries - which are all the same in my system, as I pointed out before):

$ ls -l /etc/alternatives/ | grep OpenCL
lrwxrwxrwx 1 root root 115 Aug 16 04:35 opencl-libOpenCL.so -> /opt/intel/system_studio_2019/opencl_compilers_and_libraries_18.1.0.013/linux/compiler/lib/intel64_lin/libOpenCL.so
lrwxrwxrwx 1 root root 117 Aug 16 04:35 opencl-libOpenCL.so.1 -> /opt/intel/system_studio_2019/opencl_compilers_and_libraries_18.1.0.013/linux/compiler/lib/intel64_lin/libOpenCL.so.1
lrwxrwxrwx 1 root root 119 Aug 16 04:35 opencl-libOpenCL.so.2.0 -> /opt/intel/system_studio_2019/opencl_compilers_and_libraries_18.1.0.013/linux/compiler/lib/intel64_lin/libOpenCL.so.2.0

So, the simplest thing I could do was to completely remove the broken symlink above (just rm) and create 3 new symlinks, one for each number at the end of the library name, just to be sure:

$ cd /usr/lib/x86_64-linux-gnu
$ sudo ln -s /etc/alternatives/opencl-libOpenCL.so libOpenCL.so
$ sudo ln -s /etc/alternatives/opencl-libOpenCL.so.1 libOpenCL.so.1
$ sudo ln -s /etc/alternatives/opencl-libOpenCL.so.2.0 libOpenCL.so.2.0

Now, the /usr/lib/x86_64-linux-gnu directory looks like this and everything seems to work:

$ ls -l /usr/lib/x86_64-linux-gnu/ | grep OpenCL
lrwxrwxrwx  1 root root       37 Aug 16 04:47 libOpenCL.so -> /etc/alternatives/opencl-libOpenCL.so
lrwxrwxrwx  1 root root       39 Aug 16 04:47 libOpenCL.so.1 -> /etc/alternatives/opencl-libOpenCL.so.1
lrwxrwxrwx  1 root root       41 Aug 16 04:35 libOpenCL.so.2.0 -> /etc/alternatives/opencl-libOpenCL.so.2.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.