Reputation: 3307
I'm attempting to load a dynamic library at runtime using dlopen. I am calling it like this:
dlopen("/absolute/path/to/libFoo.so", 0);
And this yields the following error:
invalid mode for dlopen(): Invalid argument
This code works perfectly on macOS, but fails on Ubuntu 18.04.4 LTS. What is the meaning of this error, and how can I fix it?
Upvotes: 2
Views: 3248
Reputation: 213877
This code works perfectly on macOS
That doesn't mean it has no bugs.
What is the meaning of this error, and how can I fix it?
From the man page: One of the following two values must be included in flags: RTLD_LAZY
, RTLD_NOW
.
You didn't include either flag, and that is a bug in your program, which GLIBC is telling you about.
To fix it, replace 0
with either RTLD_LAZY
or RTLD_NOW
, whichever is appropriate for your program.
Upvotes: 4