On Wed, September 21, 2016 10:11, probono wrote:
> 2016-09-19 16:45 GMT+02:00 Louai Al-Khanji <louai.al-kha...@qt.io>:
>> From a quick look it seems to be mostly well written. I do wonder
>> whether it might be better to use a tool other than ldd to find the
>> library dependencies. objdump -p provides the same information, and also
>> works for cross-compiles.
> ldd not only provides the name of the libraries to be loaded, but also
> the paths to the locations where they are loaded from. How would I get
> this information without using ldd?

By implementing the same algorithm?

It's pretty simple actually:

* go through $LD_LIBRARY_PATH
* go through RPath
* go through /etc/ld.so.config
(I think there are 1 or 2 more, look it up, it's documented)

RPath may be a bit tricky: normally Qt compiles it's lib path into RPath,
but with a deploy script you do not want that RPath anymore, instead you'd
want to change it to $ORIGIN (literally, not the value of a variable). So
you may have to check the location of linuxdeployqt and derive the
original lib path from there.

For each path that is being checked: find a file that matches the name,
check that it has the correct ELF platform (x86, amd64, x32, arm, etc.) -
if it matches, take it and add its dependencies to the list.

Ldd has several downsides:

* it may not be available on some platforms (e.g. some embedded devices)
* its output format may change without warning
* it cannot check programs for platforms that do not run on your host
(anything that is cross-compiled, or if the binary loader is missing or
* it is unsafe (although we'll assume that you will not compile and deploy
a program that sabotages your own System)


Development mailing list

Reply via email to