1

The link on this page (https://www.ghostscript.com/download.html) for Linux x64, gets you a .tgz with an executable binary.

However, while trying to use this binary as an .so, (after renaming it into libgs.so and putting into appropriate place) via Ghost4J, I invariably get errors as follows:

java.lang.UnsatisfiedLinkError: /tmp/jna-100923095/jna3513656669313044092.tmp: cannot dynamically load executable

Once I install the Ghostscript via apt-get install ghostscript, the same code runs fine (as it now loads an .so from /usr/lib/x86_64-linux-gnu/libgs.so.9.22)

Question: which minimal set of files should I put to some folder, so that I could link to Ghostscript dynamic library (.so) successfully, without Ghostscript being installed on the machine/container?

UPD: under Windows, this seems to be possible, the /bin folder of the installation contains both DLL and EXE files; if I put that .dll file into a win32-x86-64 folder under resources, it is being picked up by JNA (via Ghost4j) and Ghostscript instance works fine, even once I remove the "official" installation). I would like to have same behaviour (i.e. self-sufficient, self-containing JAR file) for Linux as well.

62mkv
  • 1,444
  • 1
  • 16
  • 28

1 Answers1

0

Well, I ended up building the shared object myself, using Ubuntu 18.04 installed as WSL 1 distribution, following the guidelines from here: https://www.ghostscript.com/doc/current/Make.htm#Shared_object

These were the exact commands:

./configure --without-luratech --with-system-libtiff --with-drivers=PCLXL
make so

and then, in the sobin folder, you have libgs.so, that works as expected. But sad it's not possible to download it from the official site.

62mkv
  • 1,444
  • 1
  • 16
  • 28
  • 1
    You are lucky the executable works for you on Linux frankly. Differences between Linux distributions mean that there is a decent chance that a binary built for one distribution won't work for others. We can't track all the distributions, so we only build one. If you want a shared library the expectation is that you will build it yourself. You could request such a thing from your package maintainer of course. – KenS Jul 29 '20 at 07:06
  • Great to receive replies straight from the community! Yeah, I've built the .so under WSL Ubuntu, and it seems to work under RHEL (so far!). Now I see that there's even a libgs package available for Ubuntu. That did not occur to me that it might exist. Might it be worth considering adding such disclaimer onto Downloads page on GS website? – 62mkv Jul 30 '20 at 09:19