Error running wkhtmltopdf — (error while loading shared libraries)

强颜欢笑 提交于 2019-12-04 08:47:51

问题


When my app runs (or when I run from commandline) the wkhtmltopdf command I get the following error: (showing it from command line)

#> wkhtmltopdf 
wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

I noticed the lib is indeed in the /usr/lib folder but not the /lib folder. Does it matter which one of these it is in? Is there any way to get it to recognize it?

#> ls -l /usr/lib/libXrender.so*
lrwxrwxrwx 1 root root    19 Feb 17 07:20 /usr/lib/libXrender.so -> libXrender.so.1.3.0
lrwxrwxrwx 1 root root    19 Feb 17 07:20 /usr/lib/libXrender.so.1 -> libXrender.so.1.3.0
-rwxr-xr-x 1 root root 39184 Jan 29  2010 /usr/lib/libXrender.so.1.3.0

#> ls -l /lib/libXrender.so*
ls: cannot access /lib/libXrender.so*: No such file or directory

I also checked dependencies of the lib

# ldd /usr/lib/libXrender.so.1
    libX11.so.6 => /usr/lib/libX11.so.6 (0x00002b9cb5afd000)
    libc.so.6 => /lib/libc.so.6 (0x00002b9cb5e04000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0x00002b9cb6143000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00002b9cb6347000)
    libdl.so.2 => /lib/libdl.so.2 (0x00002b9cb654d000)
    /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)

This is running on an EngineYard gentoo server


回答1:


The Unix packages x11-libs/libXext and x11-libs/libXrender are dependencies

Gentoo:

sudo emerge libXext libXrender

PDFkit wiki also explains in more detail how to get wkhtmltopdf working on engine yard. PDFkit wiki

Debian or Ubuntu:

sudo apt-get install libxrender1

Hope this helps




回答2:


I had the same, issue on Debian Squeeze, amd64. Installing libxrender1 solved the issue for me.

sudo apt-get install libxrender1



回答3:


I need also do after:

sudo apt-get install libfontconfig1



回答4:


Ran into this today on a RHEL7 machine running the static version of wkhtmltopdf. Solution was to install a few dependencies:

yum install libXrender libXext fontconfig 



回答5:


If your system is 64 bits, and your software requires 32 bits libs, you need to add the flag "i386",

for example on ubuntu:

sudo apt-get install libxrender1:i386



回答6:


I was having the exact same problem! The solution, to me, was to install the 64bit version of wkhtmltoimage.




回答7:


With Ubuntu 16 (from a fresh Docker install):

apt install -y libxrender1 libxext6




回答8:


sudo apt-get install xvfb

to install the dependency package.

Update the node-modules wkhtmltopdf index.js

wkhtmltopdf.command = 'wkhtmltopdf'; to 'wkhtmltopdf.command = 'xvfb-run wkhtmltopdf';'




回答9:


Note that there is an executable version of wkhtmltopdf distributed in a UPX compressed format, ldd and file will both report that this file is statically linked even though the payload requires shared libraries.

To check try

strings | fgrep UPX

If you see any "UPX" id strings then install upx and use "upx -d" on a copy of the file (as upx works in place) and then run ldd on the uncompressed file.



来源:https://stackoverflow.com/questions/5035601/error-running-wkhtmltopdf-error-while-loading-shared-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!