Error while loading shared libraries: libXrender.so.1 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: libXrender.so.1: 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:
	linux-vdso.so.1 =>  (0x00007fffdd3c6000)
	libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007f64cd4bd000)
	libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f64cd27a000)
	libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f64ccfcf000)
	libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f64ccdbd000)
	libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f64cca83000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f64cc868000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f64cc664000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f64cc45c000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f64cc23e000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f64cbebc000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f64cbbb3000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f64cb99c000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f64cb5d3000)
	/lib64/ld-linux-x86-64.so.2 (0x00005564cb080000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f64cb3aa000)
	libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f64cb184000)
	libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f64caf62000)
	libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f64cad5d000)
	libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (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
OR
$ 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 libXrender.so.1 
    libxrender1: /usr/lib/x86_64-linux-gnu/libXrender.so.1
    libxrender1: /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
    libxrender1-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
    

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