Trying to dynamically load libOpenCL.so
in a program from my LD_LIBRARY_PATH
which is set to ./
. I double checked that libOpenCL.so
is present in my current directory with the correct spelling, and I'm running the program below in my current directory.
#include <stdio.h>
#include <dlfcn.h>
int main(void)
{
const char* dl_path = "libOpenCL.so";
if (dlopen(dl_path, RTLD_NOW) == NULL)
printf("Cannot open shared lib: %s\n", dlerror());
else
printf("Open successful\n");
return 0;
}
This outputs: Cannot open shared lib: libOpenCL.so: cannot open shared object file: No such file or directory
It opens up fine when I call dlopen()
with the relative path string i.e. "./libOpenCL.so"
.
According to my understanding of dlopen()
's documentation, a non-empty LD_LIBRARY_PATH
should be considered in the .so
search with a few exceptions that shouldn't apply to my example. Anything else I might be doing wrong here?
This is for Arch Linux, glibc 2.29, GCC 9.1
Running it with:
LD_LIBRARY_PATH=.
gcc -o test example.c && ./test