[cfe-dev] New to Clang.

Duncan P. N. Exon Smith dexonsmith at apple.com
Sun Jun 15 13:23:03 PDT 2014


> On 2014 Jun 15, at 05:49, Sami Islam <sami_islam at hotmail.com> wrote:
> 
> Hello,
> I am new to clang and need some guidance as to where to start.
> 
> What I have done so far:
> 1. I have retrieved LLVM and CLang.
> 2. I have created a VS project using Cmake
> 3. I have built LLVM and Clang using Visual Studio 2013 and the project ALL_BUILD
> 
> What I would like to do:
> I would like to use the CLang LibTooling library to start creating a refactoring tool. 
> 
> First try: I created a Visual Studio Project included all the header files according to the following link:
> http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example/
> 
> When I try to compile I get the error "Cannot open include file: 'clang/Driver/Options.inc': No such file or directory".
> 
> I used the make file:
> ###################################################
> CLANG_LEVEL := ../..
>  
> TOOLNAME = example  #the name of your tool's executable
>  
> SOURCES := Example.cpp  #the Clang source files you want to compile
>  
> include $(CLANG_LEVEL)/../../Makefile.config
>  
> LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option
>  
> USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \
>            clangTooling.a clangParse.a clangSema.a \
>            clangAnalysis.a clangRewriteFrontend.a clangRewriteCore.a \
>            clangEdit.a clangAST.a clangLex.a clangBasic.a
>  
> include $(CLANG_LEVEL)/Makefile
> ###################################################
> 
> Second try: I copied my example.cpp file under llvm\tools\clang\tools\example and used the GNUWin32 make.
> I get the error that there is no Makefile.config in my llvm folder. I noticed that there isn't any but there is a makefile.config.in file. I renamed that to makefile.config.
> I kept getting errors like the following:
> 
> Makefile.config:278: *** missing seperator.
> When I look at the makefile on line 278 I see the following:
> #################################################
> # When ENABLE_OPTIMIZED is enabled, LLVM code is optimized and output is put
> # into the "Release" directories. Otherwise, LLVM code is not optimized and
> # output is put in the "Debug" directories.
> #ENABLE_OPTIMIZED = 1
> @ENABLE_OPTIMIZED@ -- Line 278
> 
> #################################################
> 
> If I uncomment line 277 it works but I get similar errors for other following lines.
> 
> 
> Question:
> Am I missing something?

I don't know much about Windows or the MSVC build, but it sounds like you're using the
Makefile from the source directory -- which is not the right thing.

You should use the makefile from the build directory that cmake creates.  If that's an
MSVC project, you should build that project (whatever that means).

E.g., on Mac OS X, it might look like this:

    $ git clone http://llvm.org/git/llvm.git llvm
    $ mkdir build
    $ cd build
    $ cmake -G Ninja ../llvm
    $ ninja

Hope that helps!



More information about the cfe-dev mailing list