How to produce executable with rustc?

后端 未结 2 1197
迷失自我
迷失自我 2021-01-28 18:06

If I compile this simple program fn main() { println!(\"Hello\"); } with rustc test.rs -o test then I can run it with ./test, but double c

2条回答
  •  既然无缘
    2021-01-28 18:52

    What you have described is not entirely consistent with what I observe:

    $ rustc - -o test <<< 'fn main() { println!("Hello"); }' 
    $ ./test
    Hello
    $ file test
    test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=99e97fcdc41eb2d36c950b8b6794816b05cf854c, not stripped
    

    Unless you tell rustc to produce a library with e.g. #![crate_type = "lib"] or --crate-type lib, it will produce an executable.

    It sounds like your file manager may be being too smart for its own good. It should just be trusting the executable bit and executing it.

提交回复
热议问题