How to get more info if lt_dlopen fails?

2019-07-25 08:34发布

I'm calling lt_dlopen and getting a generic file not found error (translated errno text). How can I get more information about what is actually failing, as the file is definitely there.

This is a C++ program loading a C++ library. Otherwhere in the same program I use the same command to open other libraries without a problem, thus I fear it might be something specific to this library. I've used ldd and all those dependencies of the library are met.

3条回答
仙女界的扛把子
2楼-- · 2019-07-25 09:05

I stumbled across something that kind of works:

export LD_DEBUG=all

And then proceed to sift throught the extreme mass of output. In this case I found a "lookup error" and one of the symbols could not be resolved. I'm not sure why, but that is perhaps not relevant to this question.

查看更多
\"骚年 ilove
3楼-- · 2019-07-25 09:12

From http://www.delorie.com/gnu/docs/libtool/libtool_46.html :

Function: lt_dlhandle lt_dlopen (const char *filename)

[...] If lt_dlopen fails for any reason, it returns NULL.

Function: const char * lt_dlerror (void)

Return a human readable string describing the most recent error that occurred from any of libltdl's functions. Return NULL if no errors have occurred since initialization or since it was last called.

查看更多
Lonely孤独者°
4楼-- · 2019-07-25 09:24

Recompile libtool with "-DLT_DEBUG_LOADERS" in $CFLAGS. Adjust LD_LIBRARY_PATH so that your program will find this debug libltdl.so instead of the system one. That debug version of ltdl will print explicit errors for each loader's attempt to open the target with much less verbosity than LD_DEBUG=all.

查看更多
登录 后发表回答