spa: tools: spa-inspect: Output more detailed dlopen and dlsym errors

When writing a custom SPA plugin, it is very useful to get more detailed
errors related to libdl. One common error is that a symbol is not present
because a related library was not properly linked into the plugin. With
this change, the error will tell the user about the exact missing symbol.
This commit is contained in:
Carlos Rafael Giani 2025-05-20 11:55:30 +02:00
parent d9b742cfda
commit 2fe77c47e1

View file

@ -277,11 +277,11 @@ int main(int argc, char *argv[])
data.n_support = 3; data.n_support = 3;
if ((handle = dlopen(argv[1], RTLD_NOW)) == NULL) { if ((handle = dlopen(argv[1], RTLD_NOW)) == NULL) {
printf("can't load %s\n", argv[1]); printf("can't load %s: %s\n", argv[1], dlerror());
return -1; return -1;
} }
if ((enum_func = dlsym(handle, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { if ((enum_func = dlsym(handle, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) {
printf("can't find function\n"); printf("can't find \"%s\" function: %s\n", SPA_HANDLE_FACTORY_ENUM_FUNC_NAME, dlerror());
return -1; return -1;
} }