mystor / rust-cpp

Embed C++ directly inside your rust code!
Apache License 2.0
798 stars 44 forks source link

function is never used. #14

Closed shuaimu closed 7 years ago

shuaimu commented 7 years ago

Hello. I am new to rust and want to start by playing with some cxx-rust bindings.

I followed the example from the document. The compile generated no executable binary with a warning:

warning: function is never used: `main`
  --> src/lib.rs:8:1
   |
8  | / fn main() {
9  | |     unsafe {
10 | |         cpp!([] {
11 | |             printf("Hello, World!\n");
12 | |         });
13 | |     }
14 | | }
   | |_^
   |
   = note: #[warn(dead_code)] on by default

Is this normal? Any help is appreciated.

mystor commented 7 years ago

I think your problem here is that you created a library when you intended to create a binary. Try either creating your project with cargo new --bin instead of cargo new, or rename your lib.rs file to main.rs :-)

shuaimu commented 7 years ago

I see. thanks!