kiss3d icon indicating copy to clipboard operation
kiss3d copied to clipboard

Can't run example with out manually adding `include nalgebra = "0.13.1"`

Open Cosmos547 opened this issue 6 years ago • 5 comments

Hi,

When I try to run cargo build with the simple example given I would get the following error.

     Running `rustc --crate-name kiss3D_testing src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8518de3a64155402 -C extra-filename=-8518de3a64155402 --out-dir /home/cosmos/Documents/projects/kiss3D-testing/target/debug/deps -C incremental=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/incremental -L dependency=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/deps --extern kiss3d=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/deps/libkiss3d-8785c1cfbd773f2a.rlib -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/build/glfw-sys-8b1b79aac9212207/out/lib`
error[E0463]: can't find crate for `na`
 --> src/main.rs:2:1
  |
2 | extern crate nalgebra as na;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

error: Could not compile `kiss3D-testing`.

Caused by:
  process didn't exit successfully: `rustc --crate-name kiss3D_testing src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8518de3a64155402 -C extra-filename=-8518de3a64155402 --out-dir /home/cosmos/Documents/projects/kiss3D-testing/target/debug/deps -C incremental=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/incremental -L dependency=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/deps --extern kiss3d=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/deps/libkiss3d-8785c1cfbd773f2a.rlib -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/home/cosmos/Documents/projects/kiss3D-testing/target/debug/build/glfw-sys-8b1b79aac9212207/out/lib` (exit code: 101)

I manually added the line to include nalgebra = "0.13.1" inside Cargo.toml to make the compilation success. I tried adding nalgebra = "0.14.0" which is the newest version but it would not work and will receive the following error.

   Compiling kiss3D-testing v0.1.0 (file:///home/cosmos/Documents/projects/kiss3D-testing)
error[E0308]: mismatched types
  --> src/main.rs:19:37
   |
19 |         c.prepend_to_local_rotation(&rot);
   |                                     ^^^^ expected struct `nalgebra::core::unit::Unit`, found struct `na::Unit`
   |
   = note: expected type `&nalgebra::core::unit::Unit<nalgebra::geometry::quaternion::Quaternion<f32>>`
              found type `&na::Unit<na::Quaternion<{float}>>`
note: Perhaps two different versions of crate `nalgebra` are being used?
  --> src/main.rs:19:37
   |
19 |         c.prepend_to_local_rotation(&rot);
   |                                     ^^^^

error: aborting due to previous error

error: Could not compile `kiss3D-testing`.

To learn more, run the command again with --verbose.

Thank you!

Cosmos547 avatar Mar 22 '18 20:03 Cosmos547

+1

I just tried the latest Kiss3d, 0.14 and it still has this issue, BUT you can include nalgebra 0.14 now.

I actually can't get the example to run at all, even after manually adding the nalgebra crate. It builds OK after adding nalgebra, but when I try and run it I get an error that says thread 'main' panicked at 'gl function was not loaded'

Backtrace

$RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/opengl`
thread 'main' panicked at 'gl function was not loaded', /home/adam/Documents/dev/Rust/opengl/target/debug/build/gl-9b3781492007fc89/out/bindings.rs:20624:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:380
   3: std::panicking::default_hook
             at libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:576
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:537
   6: gl::missing_fn_panic
             at ./target/debug/build/gl-9b3781492007fc89/out/bindings.rs:20624
   7: gl::BindFramebuffer
             at ./target/debug/build/gl-9b3781492007fc89/out/bindings.rs:1527
   8: kiss3d::resource::framebuffer_manager::FramebufferManager::new
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.14.0/src/resource/framebuffer_manager.rs:85
   9: kiss3d::window::window::Window::do_new
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.14.0/src/window/window.rs:375
  10: kiss3d::window::window::Window::new
             at /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/kiss3d-0.14.0/src/window/window.rs:335
  11: opengl::main
             at src/main.rs:9
  12: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  13: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:479
  14: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  15: std::rt::lang_start_internal
             at libstd/panicking.rs:458
             at libstd/panic.rs:358
             at libstd/rt.rs:58
  16: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  17: main
  18: __libc_start_main
  19: _start

Tried with Rust 1.22.0, 1.25.0 and the latest beta 1.26.0-beta.19 and all produce the same result.

I've tried manually adding the 'gl' crate to no avail.

Googling this error also turns up a similar issue in the gfx-rs library.

I'm pretty new to Rust so I apologise for not having any more info.

adam-buckley avatar May 08 '18 05:05 adam-buckley

I have the same problem, I tried building the crate and I got this:

error[E0463]: can't find crate for `na`
 --> src/main.rs:4:1
  |
4 | extern crate nalgebra as na;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `cube`.

To learn more, run the command again with --verbose.

My environment according to rustup (I am on debian testing):

$> rustup show
Default host: x86_64-unknown-linux-gnu

stable-x86_64-unknown-linux-gnu (default)
rustc 1.27.2 (58cc626de 2018-07-18)

gueltro avatar Jul 27 '18 04:07 gueltro

@gueltro Could you paste your Cargo.toml please so I can see if something is missing?

sebcrozet avatar Jul 27 '18 05:07 sebcrozet

@sebcrozet I am sorry I was missing nalgebra = "0.16" in my toml file. I added it and the demo started smoothly. Thank you!

gueltro avatar Jul 28 '18 00:07 gueltro

A year later, I had the same issue as well. This issue seems to stem from a change made to the rust language in 2018. They removed the need for extern crate in 99% of cases. Instead of defining external crates in project files, you define them in Cargo.toml and just use them in your project file (in this case main.rs).

So if you have a newer version of rust you can try declaring the nalgebra dependency in your Cargo.toml (I used the same version as in the transitive dependencies in Cargo.lock) and replace

extern cargo kiss3d; extern cargo nalgebra as na; with use kiss3d; use nalgebra as na;.

This worked for me.

sigurof avatar Oct 20 '19 19:10 sigurof