openrr / urdf-viz

visualize URDF/XACRO file, URDF Viewer works on Windows/MacOS/Linux
Apache License 2.0
413 stars 56 forks source link

Build fails with `assimp` feature #215

Closed H1rono closed 1 year ago

H1rono commented 1 year ago

Building fails if assimp feature is enabled. (Sorry if I have misunderstood something)

Compiler diagnostic:

$ cargo install urdf-viz --features assimp
# ...
   Compiling urdf-viz v0.43.1
error[E0308]: mismatched types
   --> /home/pi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/urdf-viz-0.43.1/src/assimp_utils.rs:71:13
    |
69  |         match assimp_sys::aiGetMaterialColor(
    |               ------------------------------ arguments to this function are incorrect
70  |             mat,
71  |             color_type.as_ptr() as *const i8,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> /home/pi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/assimp-sys-0.3.1/src/material.rs:146:12
    |
146 |     pub fn aiGetMaterialColor(
    |            ^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `urdf-viz` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `urdf-viz v0.43.1`, intermediate artifacts can be found at `/tmp/cargo-installake7O1`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
taiki-e commented 1 year ago

We should use c_char instead of i8 here (non-apple/non-windows aarch64 target's c_char is u8): https://github.com/openrr/urdf-viz/blob/e5f08f4f242709d10e20704068ea5e52d50b4d82/src/assimp_utils.rs#L71

H1rono commented 1 year ago

OK, I will open a PR with that solution.