Today in the push to start learning mentor Rust programming language, strive to achieve basic mastery of RUST language in a week. Encountered in the download, the installation process some problems, check a lot of information is also not clear, it is hereby recorded for a rainy day.
Rust IDE installation and system configuration macOS
Equipment: macOS Majove, the current version 10.14.6
A, Rust download and install
Since this machine is Apple, download process is very simple, command line, type:
curl https://sh.rustup.rs -sSf | sh
Enter, namely to start the installation
process, you'll be prompted to ask installation method, input
1
That is installed by default
Then automatically download some
depends, not control, until completion of the installation prompts.
In the mac systems department,
automatically configured environment variables during installation, find some friends will encounter problems environment variable configuration failed when viewing data. The installation did not encounter put aside.
After the installation is complete, see if the installation was successful:
rustc --version
cargo --version
If the two versions can be properly displayed, Rust has been installed successfully.
Then began to try to run the first program Rust, loved Hello World.
Open a text editor, enter the code
fn main(){
println!("Hello World!");
}
Save as
file.
Command in the terminal then enters
rustc hello.rs
the command will be compiled. But my computer error occurred:
error: linking with cc failed: exit code: 1
=note: "cc"....
=note: xcrun: error: invalid active developer path (/Libarary/Developer/CommandlineTools), missing xcrun at: /Libarary/Developer/CommandlineTools/usr/bin/xcrun...
The above error, the error is not the most critical tips back, many problems can cause this error. To read the notes carefully, this is simply wrong. The second note, the feedback system in the absence of xcrun "Commandline Tools", that is to say my system environmentThere is no command-line tool, it could not be achieved at the command line compiler
This is actually a good solution, a first download Xcode. (Xcode can be downloaded at the official Apple store, the size of G + 7 For my apple 128G too unfriendly _ )
After installing Xcode, open a terminal and type
xcode-select --install
Enter, pop-up boxes, and click Install agree.
After the installation is complete, you can enter the command again, if prompted "already installed" the installation was successful.
At this point go back to just fail to compile the hello function, re-enter
rustc hello.rs
successfully compile it! ! Then input
./ hello
will display "Hello World", the program proved successful operation friends ~!
Two, IDE configuration
Although compile and run successfully, but the command-line interface is not friendly enough, and decided to Rust configure an integrated development environment. After comparison, the choice of IntelliJ.
First official website to download IntelliJ, like installation, this step did not encounter problems.
Open IntelliJ, (omitted crack or activation code (escape), it is not first with a trial version), at the beginning of the interface, click the bottom right cornerConfigure -> Plungin
In the pop-up interface search
, click installation.
After a successful installation, rust Intellij IDEA environment configuration is complete, is not very simple -
Subsequently, the new rust engineering:
file --> new --> project
the left sidebar select Rust, Rust code for new construction can be friends ~
After all of the code will have their own highlighting, auto completion etc., no longer have to re-write code terminal. After the code is written,右键 -> RUN
Welcome to become a Rustacean!