1

I was trying to install a library called Openslide which failed during the ./configure step because it could not find a dependency (libjpeg).

I thought I would proceed to build libjpeg and then manually provide the library location to ./configure to make it work. After building libjpeg at ~/libjpeg, I thought I could just add ~/libjpeg/lib to LD_LIBRARY_PATH by putting the following in my bashrc and re-sourcing it LD_LIBRARY_PATH=~/libjpeg/lib:$LD_LIBRARY_PATH.

This didn't work and libjpeg still couldn't be found by the ./configure script in Openslide. I started hunting down answers online, one suggestion was to try ./configure --with-libjpeg=~/libjpeg/lib which also failed.

I eventually gave up and just did a sudo apt install, but I am still curious as to why I couldn't manually provide the location of the library. Is there a correct way to do this?

Joff
  • 383
  • 1
  • 3
  • 13

1 Answers1

1

OpenSlide uses pkg-config to find its dependencies, so you need to tell pkg-config where to find your library:

PKG_CONFIG_PATH=~/libjpeg/pkg-config ./configure …

replacing ~/libjpeg/pkg-config with the path to the directory containing libjpeg.pc.

Unfortunately the libjpeg implementation you used is very old and doesn’t provide a .pc file; you might want to use libjpeg-turbo instead (that’s what libjpeg-dev pulls in on current Debian and derivatives).

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • hmm. does it matter that the `libjpeg` build on the system does not have a `pkg-config` directory? All that was in the build was `bin`, `man`, and `lib`. Also how did you know where to track that down? Was I crazy to think it could be `LD_LIBRARY_PATH`? – Joff Nov 22 '22 at 15:07
  • Using `LD_LIBRARY_PATH` for this is a common mistake, not helped by the ambiguous variable name; [it’s only used by the dynamic loader](https://unix.stackexchange.com/a/449063/86440), not by the linker (directly). It doesn’t matter that your `libjpeg` build doesn’t have a `pkg-config` directory; all that matters is that it produces a `libjpeg.pc` file and that you point `pkg-config` at it. – Stephen Kitt Nov 22 '22 at 15:19