Eclipse on MAC OS X Does not detect LLVM toolchain

EclipseMacosClang

Eclipse Problem Overview


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: https://stackoverflow.com/questions/32726175/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?

Eclipse Solutions


Solution 1 - Eclipse

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

Solution 2 - Eclipse

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionranmView Question on Stackoverflow
Solution 1 - EclipseankiView Answer on Stackoverflow
Solution 2 - EclipsecdplayerView Answer on Stackoverflow