Hallo Everybody,
on my Laptop there is a Nvidia Card, GeForce GT 730M. I installed the drivers from the Nvidia Repository for Opensuse Tumbleweed. Its a 64bit machine. The compute rpm of Nvidia provides the following files:
But when I want to compile my little test programm with g++ main.cpp -lOpenCL the compiler can’t link to OpenCL:
/usr/lib64/gcc/x86_64-suse-linux/12/../../../../x86_64-suse-linux/bin/ld: cannot find -lOpenCL: Datei oder Verzeichnis nicht gefunden
collect2: error: ld returned 1 exit status
How can I make the linker to find OpenCL? This error persisted over many Updates of Nvidia’s kernel modules.
Hi. Fellow NVIDIA and OpenSUSE user here. Though what you’re hitting here applies not only to OpenSUSE but other Linux distros as well.
The key item you’re missing is a symlink from /usr/lib64/libOpenCL.so.1 to /usr/lib64/libOpenCL.so. For testing, you can create this by running the following command as root:
However, you’re probably wondering why this symlink isn’t already here. Well, oftentimes packages providing library dependencies are split into a base package RPM (needed for running apps linked against the package) and a “devel” package RPM. The base package contains the actual versioned library files (e.g. libOpenCL.so.1.0.0) as those are needed for runtime linking. And the devel package contains the files needed only for building (compiling and compile-time linking) with the application. The latter includes header (.h) files and symlinks to the versioned libraries from unversioned filenames (e.g. libOpenCL.so).
So I would look for a package with the same name as the one that provided the NVIDIA compute libraries, but which also has a “-devel-” in the package name. That’ll be the one to provide headers and shared library symlinks needed for building with that package’s libraries.
FWIW, here back on OpenSuSE 15.0, they hadn’t done that split, and both the versioned library files and library symlinks were all provided by the same package: