Recently we had a need to use pdftotext on a server that we couldn’t install packages on, so we decided to download the source for Xpdf and build our own copy. This is generally pretty easy, however by default it requires shared libraries to also be installed on the system that runs it, and you can’t just copy those up if you don’t have permission to write to the install locations. The fix is to build the binaries as statically linked, which means the additional libraries will be included in the main binaries. This does make the binary files larger, but that’s the price of portability.
(I’m not a compiler ninja in any way, so if you are and I’m doing this wrong, please don’t make fun of me too much!)
curl -O https://dl.xpdfreader.com/xpdf-4.04.tar.gz
tar zxvf xpdf-4.04.tar.gz
cd xpdf-4.04
cmake -DCMAKE_BUILD_TYPE=Release -DNO_FONTCONFIG=ON -DXPDFWIDGET_PRINTING=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Qt4=1 -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=1 -DCMAKE_EXE_LINKER_FLAGS="-static"
make