Linux · 2018-10-22

debian error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory

root@localhost:~# phantomjs --version
"/usr/lib/phantomjs/phantomjs: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory"

root@localhost:~# strip --remove-section=.note.ABI-tag /usr/lib64/libQt5Core.so.5

root@localhost:~# phantomjs --version
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display :99
Could not connect to any X display.

#xvfb (short for X virtual framebuffer) 虚拟显示服务,跑在内存里
#方法1:使用xvfb-run直接运行
root@localhost:~# xvfb-run phantomjs --version
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
2.1.1

#方法2:
root@localhost:~# (Xvfb :99 &) ; export DISPLAY=:99

root@localhost:~# phantomjs --version
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
2.1.1