Kaydet (Commit) c3452e67 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

More informative error message after dlopen() or LoadLibrary() has failed

Change-Id: Iedf956c9bd78d1d23e5ee68772a000f90a39810e
Reviewed-on: https://gerrit.libreoffice.org/15492Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
Tested-by: 's avatarTor Lillqvist <tml@collabora.com>
üst 5ad29825
...@@ -49,6 +49,11 @@ extern "C" ...@@ -49,6 +49,11 @@ extern "C"
); );
} }
char *_dlerror(void)
{
return dlerror();
}
void *_dlsym(void *Hnd, const char *pName) void *_dlsym(void *Hnd, const char *pName)
{ {
return dlsym(Hnd, pName); return dlsym(Hnd, pName);
...@@ -77,6 +82,13 @@ extern "C" ...@@ -77,6 +82,13 @@ extern "C"
return (void *) LoadLibrary(pFN); return (void *) LoadLibrary(pFN);
} }
char *_dlerror(void)
{
LPSTR buf = NULL;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, reinterpret_cast<LPSTR>(&buf), 0, NULL);
return buf;
}
void *_dlsym(void *Hnd, const char *pName) void *_dlsym(void *Hnd, const char *pName)
{ {
return GetProcAddress((HINSTANCE) Hnd, pName); return GetProcAddress((HINSTANCE) Hnd, pName);
...@@ -165,8 +177,8 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p ...@@ -165,8 +177,8 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p
dlhandle = _dlopen(imp_lib); dlhandle = _dlopen(imp_lib);
if (!dlhandle) if (!dlhandle)
{ {
fprintf(stderr, "failed to open library '%s' or '%s' in '%s/'\n", fprintf(stderr, "failed to open library '%s' or '%s' in '%s/': %s\n",
TARGET_LIB, TARGET_MERGED_LIB, install_path); TARGET_LIB, TARGET_MERGED_LIB, install_path, _dlerror());
free(imp_lib); free(imp_lib);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment