CMake 3.18.0 not finding libopenjpeg2

2.5k views Asked by At

Please forgive my ignorance when is comes to Cmake. I'm trying to install Poppler 0.86.1 on Centos 7 but I am stuck with an error that says CMake Error at CMakeLists.txt:208 (message): Install libopenjpeg2 before trying to build poppler. I have installed libopenjpeg2 including the dev package by running the following:

sudo yum install openjpeg2-devel

I am taking the following steps to install poppler:

wget https://poppler.freedesktop.org/poppler-0.86.1.tar.xz
tar xf poppler-0.86.1.tar.xz
cd poppler-0.86.1/
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..

Which results in the following error

 CMake Error at CMakeLists.txt:208 (message):
 Install libopenjpeg2 before trying to build poppler.  You can also decide
 to use the internal unmaintained JPX decoder or none at all.


-- Configuring incomplete, errors occurred!

This is where the failure occurs in the CMakeLists.txt

if(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2")
  find_package(OpenJPEG)
  set(WITH_OPENJPEG ${OpenJPEG_FOUND})
  if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION VERSION_LESS 2)
      message(FATAL_ERROR "Install libopenjpeg2 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all.")
  endif()
  ...

Can anyone point me in the right direction in figuring out how to get Poppler 0.86.1 to successfully install on Centos 7?

2

There are 2 answers

0
Pete Stieber On

I hit this and it was due to https://github.com/uclouvain/openjpeg/issues/1174. I modified my local copy of /lib64/openjpeg-2.3/OpenJPEGConfig.cmake to work around this.

0
Milan Hlinák On

If I remember correctly, I had the same problem when I was trying to use the latest version of the Poppler in my Docker image. I fixed it by installing libopenjp2-7-dev. Please check my answer, specifically, the second row of my Dockerfile where you can see what I installed before running cmake.