CLion linker 'cc' not found error on MacOS

Hi all,
I'm new to Rust and using both vscode and clion rust to go through some tutorials but I'm running into a strange linker error on clion which doesn't happen when running in the terminal.

From CLION build :

/Users/malpropio/.cargo/bin/cargo build --message-format=json-diagnostic-rendered-ansi --package hello_rust_clion --bin hello_rust_clion --verbose --color=always
Compiling hello_rust_clion v0.1.0 (/Users/malpropio/Projects/Rust/hello_rust_clion)
Running /Users/malpropio/.cargo/bin/rustc --crate-name hello_rust_clion --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=1d9f59dbcb98fa5f -C extra-filename=-1d9f59dbcb98fa5f --out-dir /Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/deps -C incremental=/Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/incremental -L dependency=/Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/deps
error: linker cc not found
|
= note: No such file or directory (os error 2)

From terminal :

malpropio@damballah2 hello_rust_clion % /Users/malpropio/.cargo/bin/cargo build --message-format=json-diagnostic-rendered-ansi --package hello_rust_clion --bin hello_rust_clion --verbose
Compiling hello_rust_clion v0.1.0 (/Users/malpropio/Projects/Rust/hello_rust_clion)
Running rustc --crate-name hello_rust_clion --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=1d9f59dbcb98fa5f -C extra-filename=-1d9f59dbcb98fa5f --out-dir /Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/deps -C incremental=/Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/incremental -L dependency=/Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/deps
{"reason":"compiler-artifact","package_id":"hello_rust_clion 0.1.0 (path+file:///Users/malpropio/Projects/Rust/hello_rust_clion)","manifest_path":"/Users/malpropio/Projects/Rust/hello_rust_clion/Cargo.toml","target":{"kind":["bin"],"crate_types":["bin"],"name":"hello_rust_clion","src_path":"/Users/malpropio/Projects/Rust/hello_rust_clion/src/main.rs","edition":"2021","doc":true,"doctest":false,"test":true},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":,"filenames":["/Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/hello_rust_clion"],"executable":"/Users/malpropio/Projects/Rust/hello_rust_clion/target/debug/hello_rust_clion","fresh":false}
{"reason":"build-finished","success":true}
Finished dev [unoptimized + debuginfo] target(s) in 0.82s

anyone seen this before or know what may be going on ?

cheers

OS : MacOs Monterey (Intel version)
Rustup : 1.24.3 (installed using brew rustup-init)
Rustc : 1.58.1
clang : 13.0.0

Have you installed either xcode or the xcode commandline tools? You need it to compile things on macOS. You can install the xcode commandline tools using xcode-select --install.

2 Likes

the command line tools are installed but wouldn't that also fail on the command line if it wasn't the case ?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.