Skip to content

Instantly share code, notes, and snippets.

@mre
Last active February 28, 2020 08:03
Show Gist options
  • Save mre/992910 to your computer and use it in GitHub Desktop.
Save mre/992910 to your computer and use it in GitHub Desktop.
LLVM, clang and clang++ under Eclipse

How to setup llvm and clang for eclipse

This guide is many years old is most likely outdated. I'll keep it here for reference; use at your own risk.

Tested on Mac OSX 10.6.7 with LLVM and CLANG version 2.9 Eclipse Helios Service Release 1 (Build 20100917-0705)

1) Installing LLVM and clang

Enter the following commands in a shell:

Grab the code from the repository:

svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_29/final llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_29/final/ clang

Configure and build:

./configure --enable-optimized # Removes debugging flags. Makes compiling much faster
gmake -j2                      # (64bit, 2 jobs at a time)
sudo gmake install             # This puts llvm and clang into /usr/local

2) Running LLVM in Eclipse:

Required plugins

Adjust settings

  • Go into Eclipse preferences > C/C++ > Build > Environment and click "Select".
  • Click on the box next to the PATH variable and "OK".
  • The variable will appear in the list. Click on "Edit" and enter the path to the clang installation into the "Value"-Field (i.e. /usr/local/bin)
  • Go to Preferences > LLVM and enter "usr/local/" in LLVM installation folder.

Try it out

Try to build a sample C++ project or create a new project under File > New > C++ Project. Good luck :)

Pro tip

Adjust the CDT indexer settings for faster code completion: Preferences > C/C++ > Indexer

@madhvigupta
Copy link

Thanks for sharing all the steps. I have done it so far but how to tell the eclipse to use LLVM as a compiler.

@dtvkoe
Copy link

dtvkoe commented Jul 27, 2016

the link to the llvm toolchain on the eclipse marketplace is borken.
Is there a new place where I can get the plugin?
Searching on the marketplace for LLM gives me no result

@mre
Copy link
Author

mre commented Jan 2, 2018

I'm way too late to the party here, but for anyone reading this, probably there are better ways to use LLVM with Eclipse by now.
As @dtvkoe mentioned, the link to the plugin is broken. Some quick search turned up this outdated Github project: https://github.com/TuononenP/llvm4eclipsecdt. It indicates that the llvm toolchain is now part of Eclipse CDT itself and can be selected as an installation option. I don't use Eclipse anymore myself, so I can't say for sure. Switched to Visual Studio Code a while ago.

@leonardopsantos
Copy link

Unfortunately, even with LLVM 7.0.1 on the PATH, Eclipse can't find the toolchain. It can find Cygwin, MinGW, and an ARM cross GCC, but not clang.

@danijeldomazetprivate
Copy link

danijeldomazetprivate commented Nov 21, 2019

I can't find the: "Go to Preferences > LLVM and enter "usr/local/" in LLVM installation folder." Please, more details?

@mre
Copy link
Author

mre commented Nov 21, 2019

Sorry, I'm not using Eclipse anymore and I can't check at the moment. I'm keeping the instructions around so that other people who find them can update them and maybe provide support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment