I'm trying load library library.so, when i try if exist return true, but when I use dlopen return library doesn't exist.
std::ifstream ifile("library.so"); if (ifile) { cout << "Exist!" << std::endl; } cout << "C++ dlopen demo\n\n"; // open the library cout << "Opening hello.so...\n"; void* handle = dlopen("library.so", RTLD_LAZY); if (!handle) { cerr << "Cannot open library: " << dlerror() << '\n'; return 1; }
ifile.close()before using dlopen.