linux/gcc: ldd functionality from inside a C/C++ program

前端 未结 3 1975
南旧
南旧 2020-12-11 05:42

Is there a simple and efficient way to know that a given dynamically linked ELF is missing a required .so for it to run, all from the inside of

3条回答
  •  暖寄归人
    2020-12-11 05:59

    As per ld.so(8), setting the environment variable LD_TRACE_LOADED_OBJECTS to a non-empty string will give ldd-like results (instead of executing the binary or library normally).

    setenv("LD_TRACE_LOADED_OBJECTS", "1", 1);
    FILE *ldd = popen("/lib/libz.so");
    

提交回复
热议问题