添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I'm trying to install Rust on my Macbook, which doesn't have linker (or any C compiler).

Rustup successfully produces "Rust is installed now. Great!"

The Installation - The Rust Programming Language mentions that the linker is required, but I didn't do any C development on this machine.

Is there a way to install a linker for Rust on a Macbook? Xcode can't be installed.

Here is what I'm getting:

$ brew install llvm
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)
Error: The following formula:
cannot be installed as a a binary package and must be built from source.
To continue, you must install Xcode from the App Store,
or the CLT by running:
  xcode-select --install

Can I build Rust from source on this computer (which doesn't have C)? Can I build non-Xcode toolchain from source? How?

Same thing.

$ brew install gcc
xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)
Error: The following formula:
cannot be installed as a a binary package and must be built from source.
To continue, you must install Xcode from the App Store,
or the CLT by running:
  xcode-select --install
              

Thank you. I've added my PATH with /bin directory from the untarred archive. After that (I didn't edit symlinks) I have

$ which cc
/usr/bin/cc
$ ls -l /usr/bin/cc
/usr/bin/cc -> clang
$ which clang
< path to untarred directory >/bin/clang
$ clang --version
clang version 12.0.0
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: < path to untarred directory >/bin
$ cc --version

still returns the same "xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools."

It certainly is possible, I'm using Rust on a Mac without Xcode. The "Xcode" command line tools really doesn't have much to do with Xcode, it's just a standard C, C++ and Objective-C toolchain based on Clang and LLVM. (Yeah, it probably does contain some Apple-specific CLI tools, but the point is that you don't need those in order to install Rust.)

It's possible to use Rust without Xcode in the same way it's possible to eat a soup with a fork.

In practice, Rust requires developer tools that Apple bundles with Xcode. You can make a DIY developer tools yourself, basically rebuilding everything that Xcode ships, but it's going to cause you a lot of headaches. Cargo dependencies that rely on a C compiler or Apple's system headers will cause problems too.

Homebrew will also complain about lack of Xcode tools. A Mac without Xcode is not suitable for development.

If your macOS is broken and can't have Xcode, reinstall. If you're forbidden from using Xcode by some Enterprise Corporate Policy, complain about it, because it's incredibly counter-productive (or change jobs, if you can).

If all else fails, maybe get a virtual machine and use Linux version of Rust? It will still need a linker, etc. but Linux distros come with build-essentials packages.