Cykooz / libheif-rs

Safe wrapper to libheif-sys for parsing heif/heic files
MIT License
34 stars 11 forks source link

The system library `libheif` required by crate `libheif-sys` was not found on Docker #26

Closed martinhamel closed 4 months ago

martinhamel commented 4 months ago

I have the following docker file with libheif-dev libheif1 pkg-config installed.

FROM rust:1.78 as dev

RUN apt-get update && apt-get install -y \
    fish \
    rustfmt \
    osm2pgsql \
    nodejs \
    npm \
    libheif-dev libheif1 pkg-config \
    llvm-dev libclang-dev clang

but I still get

error: failed to run custom build command for `libheif-sys v2.1.1+1.17.4`

Caused by:
  process didn't exit successfully: `/app/target/debug/build/libheif-sys-d581d88088fc7a1a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=LIBHEIF_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBHEIF_STATIC
  cargo:rerun-if-env-changed=LIBHEIF_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags libheif libheif >= 1.17

  The system library `libheif` required by crate `libheif-sys` was not found.
  The file `libheif.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - /usr/lib/x86_64-linux-gnu/pkgconfig

  HINT: you may need to install a package such as libheif, libheif-dev or libheif-devel.
Cykooz commented 4 months ago

Maybe your docker image has libheif < 1.17. Ubuntu deb-repository doesn't have libheif 1.17. You have to use external PPA to install latest version of libheif.

add-apt-repository -y ppa:strukturag/libheif
martinhamel commented 4 months ago

Yes, that was the problem. The version of libheif was 1.15.

But now I can't add the repository. Sorry for so many questions.

Traceback (most recent call last): File "/usr/bin/add-apt-repository", line 362, in sys.exit(0 if addaptrepo.main() else 1) ^^^^^^^^^^^^^^^^^ File "/usr/bin/add-apt-repository", line 345, in main shortcut = handler(source, shortcut_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line 40, in shortcut_handler return handler(shortcut, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 86, in init if self.lpppa.publish_debug_symbols: ^^^^^^^^^^ File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 126, in lpppa self._lpppa = self.lpteam.getPPAByName(name=self.ppaname) ^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 113, in lpteam self._lpteam = self.lp.people(self.teamname) ^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'people' Error: building at STEP "RUN add-apt-repository -y ppa:strukturag/libheif": while running runtime: exit status 1

martinhamel commented 4 months ago

Thanks, I got it by compiling libheif

FROM rust:1.78 as dev

RUN apt-get update && apt-get install -y \
    software-properties-common

RUN apt-get update && apt-get install -y \
    fish \
    rustfmt \
    osm2pgsql \
    nodejs \
    npm \
    cmake make libclang-dev libssl-dev pkg-config 

RUN cd
RUN git clone https://github.com/strukturag/libheif.git
RUN mkdir build
RUN cd build && cmake --preset=release ../libheif && make && make install