NickNaso / ghostscript4js

Ghostscript4JS binds the Ghostscript C API to the Node.JS world.
http://www.nacios.it
Apache License 2.0
68 stars 19 forks source link

symbol lookup error: gsapi_set_arg_encoding #25

Closed will3942 closed 4 years ago

will3942 commented 7 years ago

I can npm install fine with npm install ghostscript4js --GS4JS_HOME="/usr/lib" however when try to actually execute GS I get the following error.

This is on Debian using Docker.

node: symbol lookup error: /usr/lib/node_modules/ghostscript4js/build/Release/ghostscript4js.node: undefined symbol: gsapi_set_arg_encoding

root@eaf7e6871672:/usr/lib# ls -la | grep libgs
-rw-r--r-- 1 root root 13983398 Apr 28 09:42 libgs.a
lrwxrwxrwx 1 root root       13 Apr 28 09:42 libgs.so -> libgs.so.9.06
lrwxrwxrwx 1 root root       13 Apr 28 09:42 libgs.so.9 -> libgs.so.9.06
-rw-r--r-- 1 root root 10453152 Apr 28 09:42 libgs.so.9.06

Libraries are there and I installed everything using apt-get -y install libgs-dev ghostscript

Thanks!

NickNaso commented 7 years ago

Hi @will3942, it seems that you are using Ghostscript version 9.06 and for now ghostscript4js only supports versions from 9.19 to 9.21. I had same problem on my linux local machine. The API has been changed so I chose to stay compatible with the modern API. What you can try to do is to install new Ghostscript version.

NickNaso commented 7 years ago

Please keep me updated.

will3942 commented 7 years ago

Correct, this fixed it at least on Ubuntu. On Debian however I think the issue was that some libs (libgs.so) were installed to /usr/lib but libgss* were installed to /usr/lib/linux-x86..., on Ubuntu all libs were installed to the latter directory.

03eltond commented 7 years ago

We just ran into this too, on Debian. We tried copying usr/lib/x86_64-linux-gnu/libgss* to /usr/lib, but that didn't work. Turns out, @NickNaso is correct, there's no way this can work on 9.06. The API it is complaining about:

https://www.ghostscript.com/doc/current/API.htm#set_arg_encoding

does not exist in 9.06:

https://www.ghostscript.com/doc/9.06/API.htm

Compiling 9.21 resolved the issue.

Prinzhorn commented 6 years ago

This might not be obvious to everyone, you can create a Docker container based on Debian stretch instead of jessie. Stretch comes with ghostscript 9.20.

In my case my Dockerfile changed

before

FROM node:carbon
ENV GS4JS_HOME=/usr/lib

after

FROM node:carbon-stretch
ENV GS4JS_HOME=/usr/lib/x86_64-linux-gnu
NickNaso commented 6 years ago

@Prinzhorn Yes you are right. Do you think that if I document it could be helpful? If you want you can create a section on docs and explain how to use the module with Docker. We are trying to work on the module to avoid all these problems and to do that we are integrating the source code of Ghostscript and compile it directly from the module, so at the end you don't need to install it previously on your machine. What do you think? It could be a good idea? Thank for your feedback.

Prinzhorn commented 6 years ago

@NickNaso I've added the Docker example https://github.com/NickNaso/ghostscript4js/pull/34

We are trying to work on the module to avoid all these problems and to do that we are integrating the source code of Ghostscript and compile it directly from the module, so at the end you don't need to install it previously on your machine. What do you think? It could be a good idea? Thank for your feedback.

I honestly don't know what the best approach with native node modules is. But installing a consistent and tested version alongside the module from npm would be great, otherwise you never know what's on the host system.

03eltond commented 6 years ago

I like the idea of including the module personally, but I'm just some guy on the internet :)