Sorry, I have reread manual page for dlerror() and found that it need clear error state after call, but dlerror() in src/libc/gen/dlfcn.c does not do this: #pragma weak dlerror const char * dlerror(void) { return sorry; } So error is in FreeBSD libc, if I understand this correctly. I'll do PR.