If you encounter the error message “Error: Linker cc not found” while compiling Rust applications, it means that the required linking tools are missing from your system. This problem commonly occurs when the system lacks the necessary build tools or C/C++ compilers. Here’s how to fix the issue on different platforms.
Fixing on Linux (Including Ubuntu/WSL)
To resolve this issue on Linux-based systems, ensure that build essentials and C/C++ compilers are installed.
Open a terminal and run the following command to install build essentials:
sudo apt-get install build-essential
Fixing on macOS
For macOS, you may need to install Xcode Command Line Tools to get the necessary compiler and linker.
Open Terminal and run the following command:
xcode-select --install
Fixing on Windows
On Windows, you need Visual Studio Build Tools to acquire the necessary compiler and linker.
- Visit Visual Studio’s official website.
- Download and install Visual Studio Build Tools, ensuring you select the “C++ build tools” option.
Check GCC/Clang Installation
After installation, open Terminal and run:
gcc --version
on Windows, please open Command Prompt or PowerShell and run:
clang --version
Recompile the Rust Application
If GCC is installed, recompile the Rust application to confirm if the issue is resolved on the Terminal:
cargo run
Conclusion
Since Rust uses linking tools, your computer must have C/C++ build tools installed.