Error while loading shared libraries: on Linux

I am trying to use wkhtmltopdf command to create and convert html pages to a pdf. However, I am running into errors though as follows when try to use wkhtmltopdf via a shell or Python script:
     Creating foo.pdf …
     ~/bin/wkhtmltox/bin/wkhtmltopdf: error while loading shared libraries: cannot open shared object file: No such file or directory
     Error: foo.pdf not found.

How do I fix this problem with out installing the xserver on my Ubuntu or Debian server?

You can find the missing libs using the ldd command:
$ ldd /path/to/wkhtmltopdf
Sample outputs: =>  (0x00007fffdd3c6000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64cd4bd000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64cd27a000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64ccfcf000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64ccdbd000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64cca83000) => /lib/x86_64-linux-gnu/ (0x00007f64cc868000) => /lib/x86_64-linux-gnu/ (0x00007f64cc664000) => /lib/x86_64-linux-gnu/ (0x00007f64cc45c000) => /lib/x86_64-linux-gnu/ (0x00007f64cc23e000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64cbebc000) => /lib/x86_64-linux-gnu/ (0x00007f64cbbb3000) => /lib/x86_64-linux-gnu/ (0x00007f64cb99c000) => /lib/x86_64-linux-gnu/ (0x00007f64cb5d3000)
	/lib64/ (0x00005564cb080000) => /lib/x86_64-linux-gnu/ (0x00007f64cb3aa000) => /lib/x86_64-linux-gnu/ (0x00007f64cb184000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64caf62000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64cad5d000) => /usr/lib/x86_64-linux-gnu/ (0x00007f64cab57000)

Now you can search for missing libs using:
$ apt-cache search libXrender
In my case the following were missing

  1. libXrender: X Rendering Extension client library
  2. libfontconfig1: generic font configuration library – runtime

Fixing error while loading shared libraries on a Ubuntu/Debian Linux

Armed with this new info, I need to use the following apt-get command or apt command to install libxrender1 and libfontconfig1 to solve this issue:
$ sudo apt-get install libfontconfig1 libxrender1
$ sudo apt install libfontconfig1 libxrender1
If you are using any other Linux distro you need to search as described above and install missing libs.

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Nehal J Wani Jan 22, 2017 @ 18:07

    Another solution is to do this:

    $ sudo apt-file search 
    libxrender1: /usr/lib/x86_64-linux-gnu/
    libxrender1: /usr/lib/x86_64-linux-gnu/
    libxrender1-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum