Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a binary here that is apparently statically linked:

$ file wkhtmltopdf-amd64
wkhtmltopdf-amd64: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), 
                   statically linked, stripped

$ ldd wkhtmltopdf-amd64
not a dynamic executable

$ readelf -d wkhtmltopdf-amd64 
There is no dynamic section in this file.

But when i try to execute it, it complains that shared libs would be missing:

$ ./wkhtmltopdf-amd64 
./wkhtmltopdf-amd64: error while loading shared libraries: cannot open shared object file: No such file or directory

My questions:

  • I thought statically linked binaries do not depend on shared libraries. Can someone correct my obviously wrong assumption?
  • How can I find all the libraries this binary is depending on?

PS: The binary in question is from here:

share|improve this question
Easiest thing would probably be to download the source and compile it yourself. If probably tells you what libraries it needs in the configure script or a text file. If not the errors you get configuring and compiling it will tell you. – Grant Mar 19 '13 at 23:50

Yes, indirectly through embedded libraries.

The information below suggests that that the QT library is statically embedded in the binary. Running the binary with strace, reveals that it indeed tries to load Xorg libraries because those are not statically linked in the QT libraries. In other words, some of the statically linked libraries (most likely QT) have dependencies of their own. At least that's what I think.

wkhhtmltopdf wiki - compilation:

Before you can compile wkhtmltopdf you need to have QT installed, again you have two options: You can install the QT from your distribution, this will be fast but your wkhtmltopdf build will not have all the features of the static build, or you can compile QT your self, this takes a long time but you will get all the features.

wkhtmltopdf wiki - static (faq):

  • I'm using the static binary but the fonts are wrong, squares or all black?
    This is most likely because you do not have X11 installed or not the right X11 fonts

QtGui depends on Xorg & Co:

# qlist  qtgui |grep lib.*\.so | awk -F/ '{print $NF}' |column                                                                                                                                      

       (>>> depend on)

# qlist  qtgui |grep lib.*\.so |xargs -L1 ldd | awk '{print $1}'| sort -u|column                               

Also, I compiled the program from the repository of my distro (dynamic) and the differences between openStatic and openDynamic are:

# function openStatic { strace ./wkhtmltoimage/static/wkhtmltoimage-i386 \
      |& grep 'open.*3' |sort | grep -o '/[^"]*' ;}

# openStatic
/etc/         /usr/lib/
/lib/       /usr/lib/
/lib/         /usr/lib/
/lib/           /usr/lib/
/lib/          /usr/lib/
/lib/       /usr/lib/
/lib/           /usr/lib/
/lib/     /usr/lib/
/lib/          /usr/lib/
------ Statically embedded libraries ------     --- Dynamically linked dependencies ---
1 l/               1 ul/      2 /etc/
1 l/             1 ul/          2 /lib/
1 l/            1 ul/   2 /lib/
1 l/              1 ul/       2 /lib/
1 l/                1 ul/        2 /lib/
1 ul/gconv/gconv-modules.cache  1 ul/            2 /lib/
1 ul/gconv/            1 ul/       2 /lib/
1 ul/         1 ul/       2 /lib/
1 ul/                1 ul/     2 /lib/
1 ul/           1 ul/       2 ul/gcc/.../
1 ul/        1 ul/        2 ul/
1 ul/        1 ul/      2 ul/
1 ul/        1 ul/            2 ul/
1 ul/       1 ul/          2 ul/
1 ul/ 1 ul/        2 ul/
1 ul/    1 ul/qt4/    2 ul/
1 ul/     1 ul/qt4/     2 ul/
1 ul/      1 ul/qt4/ 2 ul/
1 ul/        1 ul/qt4/     2 ul/
1 ul/                1 ul/qt4/

more info:
static linking
your question on SO (duplicate, wink-wink)

share|improve this answer
Would be nice if someone with a real grasp of linking would add a paragraph on how this stuff really works without all the "experimentation" – Ярослав Рахматуллин Mar 22 '13 at 1:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.