Error while loading shared libraries: libXrender.so.1 on Linux

last updated in Categories , , , ,

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 1 comments/add one below):

1 comment

  1. 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
    

    Have a question? Post it on our forum!