monax3 / DirectXTex-rs

Safe Rust interface for Microsoft's DirectXTex texture processinglibrary
Apache License 2.0
0 stars 0 forks source link

Can't build the library #1

Open Detector-I opened 1 year ago

Detector-I commented 1 year ago

Hi, I tried to use this library in one of my projects I added it as a GitHub dependency and tried to build my project, but build failed with this error message

error: failed to run custom build command for `directxtex-sys v0.1.0 (https://github.com/monax3/DirectXTex-rs.git#43ab86ec)`

Caused by:
  process didn't exit successfully: `G:\..\..\target\debug\build\directxtex-sys-035892afa056856f\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-search=native=\\?\C:\dev\vcpkg\installed\x64-windows-static-md\lib
  cargo:rustc-link-lib=DirectXTex
  cargo:rustc-link-lib=Iex-3_1
  cargo:rustc-link-lib=IlmThread-3_1
  cargo:rustc-link-lib=OpenEXR-3_1
  cargo:rustc-link-lib=OpenEXRCore-3_1
  cargo:rustc-link-lib=OpenEXRUtil-3_1
  cargo:rustc-link-lib=zlib
  cargo:rustc-link-lib=Imath-3_1
  cargo:rustc-link-lib=DirectX-Guids
  cargo:rustc-link-lib=DirectX-Headers

  --- stderr
  thread 'main' panicked at 'Not able to resolve vector element?: Continue', ..\.cargo\registry\src\github.com-1ecc6299db9ec823\bindgen-0.61.0\ir\ty.rs:1144:22

any idea what is the problem? the error itself isn't clear so Im not sure what to do... also do you plan to continue this project? it will be awesome to have a complete DirectXTex binding for rust

monax3 commented 1 year ago

The reason is probably going to be because all my post-90s C++ knowledge came from hacking this thing to work originally. I'll have a look at making it compile.

The crate was built as a dependency for a different project and that's how I worked out its API. Without a purpose to help shape it it's hard for me to continue working on it.

Detector-I commented 1 year ago

thank you for the answer, my current need is just converting a texture between some formats, so I think the current project is enough for me... I myself grow tired of using cxx and code all my DirectXTex codes in c++ and use it in my rust codes having such thing can be a big help, especially because there isn't much complete alternative... although there was some talk in DirectXTex repo itself about creating a binding, so I think if the project get a good shape for it base it will get more contributors...

monax3 commented 1 year ago

I don't know if this will fix your issue since I don't know the actual cause but I updated the deps including bindgen and made it compile with the recent DirectXTex changes which inlined a few more functions so maybe it'll work for you now?

Detector-I commented 1 year ago

I don't know if this will fix your issue since I don't know the actual cause but I updated the deps including bindgen and made it compile with the recent DirectXTex changes which inlined a few more functions so maybe it'll work for you now?

thank you for the fast update I updated the library and now im getting this error now

...
...\.cargo\git\checkouts\directxtex-rs-0729e1ccdc3b8e9e\6247589\sys\wrapper\DirectXTexWrapper.hpp(1): fatal error C1083: Cannot open include file: 'DirectXTex.h': No such file or directory
  exit code: 2

am I not doing something? I installed DirectXTex through vcpkg with x64-windows-static-md triplet

monax3 commented 1 year ago

I believe this is because I've only tested with x64-windows-static, I ditched the static_crt flag, see if that helps. I'll switch to -md in the future for better compatibility.

Detector-I commented 1 year ago

still same error... maybe its because the way that you set up your include directory? because seems like in my machine it can't find the header... did you used the headers from vcpkg?

monax3 commented 1 year ago

https://github.com/monax3/DirectXTex-rs/blob/a36c6b0e4b0cd52c0271d81b29fa54406c8f8c7b/sys/build.rs#L71-L82

The include paths are pulled from vcpkg so there's no reason I can think of it should fail to find them, especially after generating the bindings succeeds.

Detector-I commented 1 year ago

dont know what is the problem but it still dont work... maybe the problem have something to do with my system?!

monax3 commented 1 year ago

I don't have enough experience with this kind of thing to say for sure. Maybe migrating to cxx instead of the custom wrapper library would make it less system dependent.

I do think that cc picks clang to compile on my system and cl on yours but I'm not sure why it makes that determination.

monax3 commented 1 year ago

I've now tested it with both cl and clang on both x64-windows-static and x64-windows-static-md (the latter needed fixes to link with clang) across release and debug and I can't replicate your issue. I'm sorry but it I'm at a loss now.

I also looked into migrating to cxx, which seems like a lot of work for external libraries, and autocxx which might work once its bindgen is upgraded.

Detector-I commented 1 year ago

I've now tested it with both cl and clang on both x64-windows-static and x64-windows-static-md (the latter needed fixes to link with clang) across release and debug and I can't replicate your issue. I'm sorry but it I'm at a loss now.

I also looked into migrating to cxx, which seems like a lot of work for external libraries, and autocxx which might work once its bindgen is upgraded.

thank you for your work and help, so seems like the problem is sadly coming from my machine... not matter how I tried I couldn't fix it, so I resorted to use the library in C++ and use C++ inside rust with CXX (which is a pain)