Cykooz / libheif-rs

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

unresolved externals [Windows] #6

Closed Galileo-dev closed 1 year ago

Galileo-dev commented 2 years ago

I've used Vcpkg to install libheif and linked it using vcpkg-rs but I cannot get it to work. I've tried linking manually but wasn't very successful the only thing that has worked so far is running this in docker and installing Debian package.


cargo.toml

[package]
name = "app"
version = "0.1.0"
edition = "2021"
build = "src/build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
vcpkg = "0.2.15"

[dependencies]
libheif-sys = "1.12.0"
vcpkg = "0.2.15"


build.rs

fn main() {
    vcpkg::find_package("libheif").unwrap();
}


main.rs

use libheif_sys as lh;

fn main() {
    unsafe {
        let ctx = lh::heif_context_alloc();
    }
}

results in

PS D:\Programming\Github Restoration Project\Working-Heic-Decoding\app> cargo run 
    Blocking waiting for file lock on build directory
   Compiling app v0.1.0 (D:\Programming\Github Restoration Project\Working-Heic-Decoding\app)
warning: unused variable: `ctx`
 --> src\main.rs:9:13
  |
9 |         let ctx = lh::heif_context_alloc();
  |             ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`
  |
  = note: `#[warn(unused_variables)]` on by default

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "D:\\Programming\\Github Restoration 
Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.1kx4a8au13ywcbhl.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.256xf6ka02050k8k.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.3mn42k4e2swv09hh.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.4apfu9h52azcxapt.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.4xcjw54wh0osko4q.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.pb26mdlbxlkh8qf.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.ug49cnachrpk6w9.rcgu.o" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.2mtygy96mi7whm6u.rcgu.o" "/LIBPATH:D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps" "/LIBPATH:D:\\Programming\\c++\\vcpkg\\installed\\x64-windows-static-md\\lib" "/LIBPATH:C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "heif.lib" "x265-static.lib" "libde265.lib" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\liblibheif_sys-9c02951885835332.rlib" "D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\liblibc-992ce8d8621cab5d.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-77c29e3b2a96c9a6.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-fac20c79897f2b3d.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-a900fec85d21ec5f.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-2803b5471132ab91.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-bd7c3f8e84ab3746.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-6353ac840b4a82ca.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-8b22f250a6b6c0c3.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-837411c15bbbd755.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-6e0180ba426c6f71.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-8fee164e10a5c1ee.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-433995d9d73cd404.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-d681750c6d1718a3.rlib" "C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-fd343f19f347f62a.rlib" "heif.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\Programming\\Github Restoration Project\\Working-Heic-Decoding\\app\\target\\debug\\deps\\app.exe" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\fionn\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note:    Creating library D:\Programming\Github Restoration Project\Working-Heic-Decoding\app\target\debug\deps\app.lib and object D:\Programming\Github Restoration Project\Working-Heic-Decoding\app\target\debug\deps\app.exp
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_version referenced in function "char const * __cdecl libde265_plugin_name(void)" (?libde265_plugin_name@@YAPEBDXZ)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_width referenced in function "struct heif_error __cdecl convert_libde265_image_to_heif_image(struct libde265_decoder *,struct de265_image const *,struct heif_image * *)" (?convert_libde265_image_to_heif_image@@YA?AUheif_error@@PEAUlibde265_decoder@@PEBUde265_image@@PEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_height referenced in function "struct heif_error __cdecl convert_libde265_image_to_heif_image(struct libde265_decoder *,struct de265_image const *,struct heif_image * *)" (?convert_libde265_image_to_heif_image@@YA?AUheif_error@@PEAUlibde265_decoder@@PEBUde265_image@@PEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_chroma_format referenced in function "struct heif_error __cdecl convert_libde265_image_to_heif_image(struct libde265_decoder *,struct de265_image const *,struct heif_image * *)" (?convert_libde265_image_to_heif_image@@YA?AUheif_error@@PEAUlibde265_decoder@@PEBUde265_image@@PEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_bits_per_pixel referenced in function "struct heif_error __cdecl convert_libde265_image_to_heif_image(struct libde265_decoder *,struct de265_image const *,struct heif_image * *)" (?convert_libde265_image_to_heif_image@@YA?AUheif_error@@PEAUlibde265_decoder@@PEBUde265_image@@PEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_plane referenced in function "struct heif_error __cdecl convert_libde265_image_to_heif_image(struct libde265_decoder *,struct de265_image const *,struct heif_image * *)" (?convert_libde265_image_to_heif_image@@YA?AUheif_error@@PEAUlibde265_decoder@@PEBUde265_image@@PEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_full_range_flag referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_colour_primaries referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_transfer_characteristics referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_image_matrix_coefficients referenced in function "struct heif_error __cdecl 
libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_new_decoder referenced in function "struct heif_error __cdecl libde265_new_decoder(void * *)" (?libde265_new_decoder@@YA?AUheif_error@@PEAPEAX@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_start_worker_threads referenced in function "struct heif_error __cdecl libde265_new_decoder(void * *)" (?libde265_new_decoder@@YA?AUheif_error@@PEAPEAX@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_free_decoder referenced in function "void __cdecl libde265_free_decoder(void *)" (?libde265_free_decoder@@YAXPEAX@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_push_NAL referenced in function "struct heif_error __cdecl libde265_v1_push_data(void *,void const *,unsigned __int64)" (?libde265_v1_push_data@@YA?AUheif_error@@PEAXPEBX_K@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_flush_data referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_decode referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_get_next_picture referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_release_next_picture referenced in function "struct heif_error __cdecl libde265_v1_decode_image(void *,struct heif_image * *)" (?libde265_v1_decode_image@@YA?AUheif_error@@PEAXPEAPEAUheif_image@@@Z)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_init referenced in function "void __cdecl libde265_init_plugin(void)" (?libde265_init_plugin@@YAXXZ)
          heif.lib(heif_decoder_libde265.cc.obj) : error LNK2019: unresolved external symbol __imp_de265_free referenced in function "void __cdecl libde265_deinit_plugin(void)" (?libde265_deinit_plugin@@YAXXZ)
          D:\Programming\Github Restoration Project\Working-Heic-Decoding\app\target\debug\deps\app.exe : fatal error LNK1120: 20 unresolved externals

warning: `app` (bin "app") generated 1 warning
error: could not compile `app` due to previous error; 1 warning emitted
Cykooz commented 2 years ago

Sorry but I use Windows for playing games only. I could not help you with compiling Rust applications for Windows at this time. May be in future I will have some time to explore your issue.

chadaustin commented 2 years ago

Thanks for the build.rs. It worked for me. I had to run:

D:\projects\vcpkg>.\vcpkg.exe install --triplet=x64-windows-static-md libheif

And then, with your build.rs in my project, it works.

I have Visual Studio 2019 Community installed with whatever the current Windows SDK and MSVC versions are.