While trying to load a module (shared object) through dlopen, it fails to load.
Say, I have testshobj.c having the following:
// testobj.c
int dummy() {
return 5;
}
Now, I compile and link testobj.c as shared object named testshobj.pm tjrough g++ compiler:
g++ testshobj.c -G -o testshobj.pm
Now, I have testdlopen.c as below:
#include <iostream>
using namespace std;
#include <dlfcn.h>
int main(int argc, char **argv) {
const char *modname = "testshobj.pm";
void *handle = dlopen(modname,RTLD_LAZY);
if(!handle) {
cout << "can't load module: " << modname << ": " << dlerror() << endl;
return(1);
}
return 0;
}
But, it says, can't load module: testshobj.pm: ld.so.1: testdlopen: fatal: testshobj.pm: open failed: No such file or directory
My Q: What is the default path in dlopen call? If I use
const char *modname = "./testshobj.pm";
instead of
const char *modname = "testshobj.pm";
There is no problem. What about the default, i.e. if I omit ./?