ref: 94680b3c3689fb0e610c23bbac5defd4191da5f0 bibliogram-docs/docs/Guide: Sharp on Raspberry Pi.md -rw-r--r-- 3.8 KiB
94680b3cCadence Ember Update instances list 7 months ago

#Guide: Installing Sharp on Raspberry Pi

Overview: If you have problems when installing Bibliogram (running npm install) with error messages related to sharp or libvips, this page will help you install the dependencies.

#The problem

Bibliogram requires a recent version of sharp, which requires a recent version of libvips. Unfortunately, at this time, the packaged version of libvips provided by apt is too old. You need to compile it yourself.

It's easy to do once you know how to do it, which is why this guide was written.

#The solution

#Install libvips dependencies

Using your package manager, install libjpeg-dev, ideally the turbo version. To do this, you first need to know which versions are available to you. Type apt update then apt list libjpeg\*. This will output something like this:

$ apt list libjpeg\*
Listing... Done
libjpeg-dev/oldstable 1:1.5.1-2 all
libjpeg-progs/oldstable 1:9b-1 armhf
libjpeg-turbo-progs/oldstable 1:1.5.1-2 armhf
libjpeg62/oldstable 1:6b2-2 armhf
libjpeg62-dbg/oldstable 1:6b2-2 armhf
libjpeg62-dev/oldstable 1:6b2-2 armhf
libjpeg62-turbo/oldstable,now 1:1.5.1-2 armhf [installed]
libjpeg62-turbo-dev/oldstable,now 1:1.5.1-2 armhf [installed]
libjpeg7/oldstable 7-2 armhf
libjpeg7-dbg/oldstable 7-2 armhf
libjpeg8/oldstable 8d1-2 armhf
libjpeg8-dbg/oldstable 8d1-2 armhf
libjpeg8-dev/oldstable 8d1-2 armhf
libjpeg9/oldstable 1:9b-1 armhf
libjpeg9-dbg/oldstable 1:9b-1 armhf
libjpeg9-dev/oldstable 1:9b-1 armhf

Look for one that has -turbo-dev at the end. The numbers just before (in my case libjpeg62) might be different. Install that package. In my example, you would write sudo apt install libjpeg62-turbo-dev.

#Download and compile libvips

Follow the instructions on the libvips website about how to download and compile libvips: https://libvips.github.io/libvips/install.html#building-libvips-from-a-source-tarball

Those instructions will have you download a .tar.gz file, decompress it, then ./configure, make, sudo make install, and sudo ldconfig.

During this process, you might encounter errors about other missing dependencies. Refer to libvips' installation page to see which other packages you might need.

If you encounter errors, especially during the ./configure step, you most likely need to install other dependencies. If you did need to install other dependencies, please edit this guide to say which ones.

#Install sharp

Sharp is installed at the same time as the other packages required by Bibliogram. Just run npm install or npm install --no-optional. If you have already installed and just need to rebuild sharp (for example, if you installed it previously but with an old libvips library), you can use npm rebuild sharp instead.

#Restart bibliogram

Bibliogram needs to be restarted to use the new libraries.

And that's it! You're done!!

If it doesn't work, keep reading...


So you've done all the steps and installed Sharp but Bibliogram produces the following errors:

node: symbol lookup error:  /home/pi/bibliogram/stage/node_modules/sharp/build/Release/sharp.
node: undefined symbol: vips_foreign_heif_compression_get_type

This means that you have 2 instances of libvips installed: the one you compiled and another one. You need to remove the other one because it's too old.

If you previously installed libvips through apt you can remove it with apt remove libvips.

#About this guide

This guide was written by narF, who you can contact if you have questions about Bibliogram on Raspberry Pi. For other questions about Bibliogram, see the project's information page: https://git.sr.ht/~cadence/bibliogram