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

@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