72

I'm trying to work with eclipse to compile/debug C/C++ applications on MAC OSX using LLVM/Clang.

I know I have the toolchain correctly installed as I can compile with it from the terminal using a makefile, and when running clang -v I get the LLVM version + install dir correctly.

I downloaded a fresh copy of eclipse C++ (Mars) + installed the LLVM support plugin and followed: Unable to install LLVM toolchain for Eclipse CDT

Copied the install dir path from the clang -v output to the LLVM part in the preferences -> c++ -> LLVM, but it seems eclipse does not detect the toolchain.

It does not appear as an option when creating a new C++ project unless I uncheck the "only show supported toolchains on the target" checkbox , and when I do uncheck it and create a LLVM project for MACOS in the build process it says:

Toolchain "LLVM with Clang (MacOSX)" is not detected.
Refer to "C/C++ Development User Guide", "Before you begin" how to install toolchains.

All it says in the manual is to install Xcode to get the toolchain running , which I obviously did as it is working from the terminal.

Any ideas? How does Eclipse detect the toolchain exists?

2 Answers 2

0

In Xcode app menu > Toolchains > set the one you want to use.

And set the environment variable export TOOLCHAINS=org.llvm.12.0.1. See the following steps to find the correct value of the env var.

If you just downloaded the compiler, headers etc., and no xctoolchain, then do this:

  • Copy /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain to ~/Library/Developer/Toolchains/

  • Delete the contents of ~/Library/Developer/Toolchains/XcodeDefault.xctoolchain/usr.

  • Either copy the share, libexec, lib, include, bin folders from the LLVM binaries to these locations inside ~/Library/Developer/Toolchains/XcodeDefault.xctoolchain/usr. Or you can create symlinks.

  • Edit the ~/Library/Developer/Toolchains/XcodeDefault.xctoolchain/ToolchainInfo.plist to change the Identifier to whatever you want.

Simply downloading the binaries doesn't make it a "toolchain" that Xcode expects like in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

2
  • How does this affect Eclipse?
    – mmmmmm
    Jan 5 at 22:18
  • xcode's toolchain selection affects system wide compiler detection if PATH doesn't interfere @mmmmmm
    – anki
    Jan 6 at 12:24
-2

Its highly likely this is fixed in latest version of Eclipse. At date this question was asked, you were using 'Mars'. This version of Eclipse is superseded by 'Neon' and then 'Oxygen' which is current as of end of January 2018. I've seen a reference to this issue being solved with 'Neon' edition as it was a bug in 'Mars'. I cannot personally confirm this though.

In addition if you manually installed clang/llvm instead of included apple version try using homebrew instead. There are some clear instructions here on using it under OSX/macOS in relation to clang/llvm.

2
  • It doesn't, its just that it does give a clean way of ensuring you have clang/llvm installed with toolchain and how to set PATH variables. Regarding Eclipse configuration this might assist.github.com/TuononenP/llvm4eclipsecdt/blob/master/README.md
    – cdplayer
    Jan 27, 2018 at 11:17
  • It ius not tested on MacOS and Does not yet work with LLVM 3.2. so not much use
    – mmmmmm
    Jan 27, 2018 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.