godot-rust / gdnative

Rust bindings for Godot 3
https://godot-rust.github.io
MIT License
3.62k stars 210 forks source link

Unable to compile hello-world example #162

Closed Barugon closed 4 years ago

Barugon commented 5 years ago

I get the following errors (rust 1.34.1):

error[E0658]: The attribute `inherit` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
 --> src/lib.rs:5:3
  |
5 | #[inherit(Node)]
  |   ^^^^^^^

error[E0658]: The attribute `methods` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> src/lib.rs:10:3
   |
10 | #[methods]
   |   ^^^^^^^

error[E0658]: The attribute `export` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> src/lib.rs:21:5
   |
21 |   #[export]
   |     ^^^^^^

error: cannot find derive macro `NativeClass` in this scope
 --> src/lib.rs:4:10
  |
4 | #[derive(NativeClass)]
  |          ^^^^^^^^^^^

error[E0061]: this function takes 1 parameter but 0 parameters were supplied
  --> src/lib.rs:31:10
   |
31 |   handle.add_class::<HelloWorld>();
   |          ^^^^^^^^^ expected 1 parameter

error[E0277]: the trait bound `HelloWorld: gdnative_core::class::NativeClass` is not satisfied
  --> src/lib.rs:31:10
   |
31 |   handle.add_class::<HelloWorld>();
   |          ^^^^^^^^^ the trait `gdnative_core::class::NativeClass` is not implemented for `HelloWorld`

error: aborting due to 6 previous errors
karroffel commented 5 years ago

You don't seem to be using qualified names for the macros, did you add a use gdnative::*; or #[macro_use] extern crate gdnative; to your file?

T0mstone commented 5 years ago

There seems to be something wrong with the crates.io entry for this crate. I had this issue too, after I replaced gdnative = "0.5.0" in the dependencies with

[depencdencies.gdnative]
git = "git://github.com/GodotNativeTools/godot-rust"

and replaced #[derive(NativeClass)] > #[derive(gdnative::NativeClass)] #[inherit(Node)] > #[inherit(gdnative::Node)] #[methods] > #[gdnative::methods] (edition 2018 BTW) it worked

edit: I have to mention I didn't use the hello world example directly, I created my own project with the same code as the hello world example

karroffel commented 5 years ago

Yes, the newest version with the procedural macros is not on crates.io yet. It has to be a git (or path) dependency for now.

Barugon commented 5 years ago

Thanks @T0mstone. I'll give that a try.

[edit] It works. BTW, I didn't need to qualify the macro names i.e. gdnative::NativeClass.

Barugon commented 5 years ago

Closing this issue since it works, although it really should mention in the readme that you need the github version of gdnative.

rainbyte commented 5 years ago

I also think the readme should have some kind of warning about this, and also links to a version of the examples which works with the package published on crate.io.

dsnopek commented 4 years ago

This appears to still be a thing? I also had to switch to the Git version in order to build the code that's in the README.md, which is confusing. If the README.md instructions are going to sometimes not work between releases, maybe don't even include them? Or maybe them super generic, like showing how to install the Git version or crate.io version, and then tell users to run cargo doc to get more information?

Barugon commented 4 years ago

In the readme, this:

[dependencies]
gdnative = "0.5.0"

should probably be replaced with this:

[dependencies]
gdnative = { git = "git://github.com/GodotNativeTools/godot-rust" }
Barugon commented 4 years ago

Thanks @karroffel