ocamllabs/ocaml-ctypes — pull request #189 by fdopen (2014-10-13 09:14:51+00:00)
Title: better exception handling in case of RTLD_NOLOAD

if `RTLD_NOLOAD` is specified in the flags, both dlopen and dlerror could return NULL. Raising `Failure "dl_error: expected error, but no error reported"` in such cases is not intuitive.

example:
```c
void * h = dlopen("not_exists.so",RTLD_NOW|RTLD_NOLOAD);
char * error = dlerror();
/* h: NULL, error: not_exists.so: cannot open shared object file: No such file or directory */

void * h = dlopen("exists_but_not_loaded.so",RTLD_NOW|RTLD_NOLOAD);
char * error = dlerror();
/* h: NULL, error: NULL */
```

The manpage says "this flag is not specified in POSIX.1-2001", but at least freebsd and linux are consistent how to handle these cases.