Reputation: 27813
I'm trying to bind against the CUDA library shared. As a quick verification I wrote the following code:
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
void *handle;
handle = dlopen ("libcuda.so", RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
dlclose(handle);
}
This fails with libcuda.so: cannot open shared object file: No such file or directory.
However, if I check ldconfig I get:
ldconfig -p | grep libcuda
libcuda.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcuda.so.1
libcuda.so.1 (libc6) => /usr/lib/i386-linux-gnu/libcuda.so.1
libcuda.so (libc6) => /usr/lib/i386-linux-gnu/libcuda.so
So it seems that libcuda.so
does exist and is seen by the system. So why is dlopen()
failing?
This is on Ubuntu 14.04.
Upvotes: 1
Views: 634
Reputation: 53006
I can see from your ldconfig -p
that there is no symlink for libcuda.so.1
x86_64, you just need to create it, try
sudo ln -svf /usr/lib/x86_64-linux-gnu/libcuda.so{.1,}
it might be the case that you don't have the -dev
package installed.
Or simply change
handle = dlopen ("libcuda.so", RTLD_LAZY);
to
handle = dlopen ("libcuda.so.1", RTLD_LAZY);
but the first solution is better because when you link dynamically to libcuda.so.1
with -lcuda
the symlink migh be mandatory.
Upvotes: 1