dladdr does not return full path in dli_fname

1.9k Views Asked by At

I use dladdr to get full path to the library:

Dl_info dl_info;
int ret = dladdr((void*)&func, &dl_info);
if (ret)
            // use dl_info.dli_fname;

It works fine. However, if I rename the folder with the build (and then run again), dli_fname does not contain full path, only file name of the library. Why is that?

There're other steps except renaming build folder (misc. cmake changes, mostly related to install functionality), but nevertheless the issue appears only after renaming (i.e. the application is run not from the build folder).

1

There are 1 best solutions below

0
On

dl_info.dli_fname not always contain full path in android ( see here)

This is a workaround in this case: see my answer