Cykooz / libheif-sys

Rust bindings to libheif-dev
MIT License
10 stars 9 forks source link

pkg_config doesn't work on Windows #3

Closed chadaustin closed 1 year ago

chadaustin commented 1 year ago

I think https://github.com/Cykooz/libheif-sys/commit/fcfba4e09d9cfce5a06edf52f1c4fb8d4a365688 broke the build on Windows:

The following warnings were emitted during compilation:

warning: `"pkg-config" "--libs" "--cflags" "libheif" "libheif >= 1.14"` did not exit successfully: exit code: 1

error: failed to run custom build command for `libheif-sys v1.14.3`

Caused by:
  process didn't exit successfully: `D:\HOME\vault\projects\imagehash\target\debug\build\libheif-sys-5ea8e5c56504397d\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=LIBHEIF_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc
  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-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc
  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-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc
  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-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  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-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc
  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-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc
  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-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=`"pkg-config" "--libs" "--cflags" "libheif" "libheif >= 1.14"` did not exit successfully: exit code: 1
  error: could not find system library 'libheif' required by the 'libheif-sys' crate

  --- stderr
  Package libheif was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libheif.pc'
  to the PKG_CONFIG_PATH environment variable
  Package 'libheif', required by 'virtual:world', not found
  Package 'libheif', required by 'virtual:world', not found
chadaustin commented 1 year ago

Oh, the original diff broke the build on my Ubuntu 18 machine too, but that's because the pkg-config invocation is constrained to libheif 1.14 and the PPA only has 1.13 for Ubuntu 18.

I'm not blocked -- I can stick with my current Cargo.lock -- but I wanted to mention that too.

Cykooz commented 1 year ago

I've released version 1.14.4. This version of the crate uses vcpkg crate instead of pkg-config if build target is Windows.

Also you can use cargo-vcpkg to build libheif with help of cargo command:

cargo vcpkg -v build
chadaustin commented 1 year ago

Thank you!