Compile grace with PDF support (via pdflib)

If you build (xm)grace without the presence of libpdf, you won’t be able to save figures as PDF files. I compiled both — libpdf and grace — as non-privileged user:

Build libpdf

If you want to keep it cheap, you should use the lite version of libpdf. I used version 7.0.5 lite. The build process worked very uncomplicated. As installation directory tree, I chose a place where I have full write access to and where I already placed other self-built software.

./configure --prefix=/home/bioinfp/jang/apps
make
make install
Build grace

I chose to built the 5.1.22 version. Now, we have to make sure that

  • the test scripts during configure and
  • the compiler and linker

will find the newly built pdflib (namely, the header and shared object files). Therefore , we will make use of several environment variables. At first, store the actual paths, which looked like that for me:

PDFINCLUDE=/home/bioinfp/jang/apps/include
PDFLIB=/home/bioinfp/jang/apps/lib

Then, during configure, we will tell the compiler and linker to look there for header and library files via the environment variables CFLAGS, CPPFLAGS, and LDFLAGS. Additionally, we will add the path stored in PDFLIB to the search path for libraries during binary execution via LD_LIBRARY_PATH. This is required already during configure due to some specific testing method for the existence of pdflib. The resulting configure command, as it worked for me, looks like:

./configure --prefix=/home/bioinfp/jang/apps/grace --enable-pdfdrv CPPFLAGS="-I $PDFINCLUDE" CFLAGS="-I $PDFINCLUDE" LDFLAGS="-L $PDFLIB" LD_LIBRARY_PATH=$PDFLIB:$LD_LIBRARY_PATH

If configure was successfull, compile:

make

Test it:

LD_LIBRARY_PATH=$PDFLIB:$LD_LIBRARY_PATH ; ./src/xmgrace -version

Side note: Here, you already see that from now on, whenever you want to start the grace executable, you at first have to add the path of libpdf’s shared object files to the environment variable LD_LIBRARY_PATH. This is because we were not able to place the libpdf library files to the proper place (like to /usr/local/lib). You can inform yourself about this topic quite well at this point. And here you can read why this approach, in general, is not a good approach — but we have no other choice here.

So, the output of the command above should contain something like that:

Registered devices:
X11 PostScript EPS PDF MIF SVG PNM JPEG PNG Metafile

There should definitely be the PDF device now :-) For me it obviously worked, so I proceeded with the installation:

make install

To automatically set LD_LIBRARY_PATH correctly whenever you call xmgrace (or any of the other executables the installation created — yes, there are some more: convcal, fdf2fit, gracebat, grconvert), you can follow two approaches:

  • edit your ~/.bashrc file (or the comparable file for other shells) and change your LD_LIBRARY_PATH globally. This is considered to be the “worst” approach, but should work fine under normal circumstances.
  • for each executable, create a “wrapper shell script” that at first sets LD_LIBRARY_PATH and then executes the original executable. Make sure that these wrapper scripts are in PATH before the directory where the original executables are in.

Leave a Reply

Your email address will not be published. Required fields are marked *

Human? Please fill this out: * Time limit is exhausted. Please reload CAPTCHA.