[cfe-dev] how to build my clang based tool

Zhongxing Xu xuzhongxing at gmail.com
Sun Oct 11 19:33:17 PDT 2009


The simple way is to use llvm/clang as static/shared libraries. You
can put your source files wherever you want, and write a Makefile
manually, like this:

INCLUDE = -I$(HOME)/llvm/include -I$(HOME)/llvm/tools/clang/include

CXXFLAGS = -g -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS \
           -fno-exceptions -fno-rtti \
           $(INCLUDE)

LIBS = -L$(HOME)/llvm/Debug/lib \
       -lclangFrontend \
       -lclangCodeGen \
       -lclangAnalysis \
       -lclangRewrite \
       -lclangSema \
       -lclangAST \
       -lclangParse \
       -lclangLex \
       -lclangBasic \
       -lclangIndex \
       -lLLVMBitWriter \
       -lLLVMAsmParser \
       -lLLVMArchive \
       -lLLVMBitReader \
       -lLLVMCore \
       -lLLVMSupport \
       -lLLVMSystem \
       -lLLVMCodeGen \
       -lLLVMAnalysis \
       -lLLVMTarget \
       -ldl -lpthread

HEADERS =

OBJS = foobar.o

foobar: $(OBJS) $(HEADERS)
	g++ -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -fno-exceptions -fno-rtti \
            -o $@ -g $(OBJS) $(LIBS)

On Sun, Oct 11, 2009 at 12:32 AM, moataz ragab <mtzrgb at gmail.com> wrote:
> I would like to use the build system of llvm to build my tool that is based
> on clang.
>
> I made a new directory under clang/tools with the name of the tool
> "polyextract". I copied the CMakelist.txt and Makefile from the clang-cc and
> modified them
> I then configure from llvm trunk and make, but unfortunately I only get the
> object file generated and no executable is generated in the Debug/bin
>
> I would appreciate your help. Sorry I am not familiar with the build
> systems.
>
> Attached are the files I modified
>
> Thanks
> Moataz
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>



More information about the cfe-dev mailing list