2016-04-12 97 views
1

我有一個項目(這有效),我試圖在我的Mac上進行編譯。它使用了各種各樣的東西,包括LLVM,這是我唯一沒有安裝的東西。所以我按照這裏的說明:http://www.isi.edu/~pedro/Teaching/CSCI565-Spring15/Projects/Project1-LLVM/LLVMInstructions-MacOSX10.9.pdf在Mac OS X上使用LLVM進行安裝和編譯

這似乎工作,但我的生成文件要求我安裝LLVM 3.3,而該教程是爲LLVM 3.5。現在,這兩個前和安裝後,當我運行使我得到以下錯誤:

$ make 
compiling cpp yacc file: expr-codegen.y 
output file: expr-codegen 
bison -b expr-codegen -d expr-codegen.y 
/bin/mv -f expr-codegen.tab.c expr-codegen.tab.cc 
flex -oexpr-codegen.lex.cc expr-codegen.lex 
clang -g -c decaf-stdlib.c 
clang++ -o ./expr-codegen expr-codegen.tab.cc expr-codegen.lex.cc decaf-stdlib.o `llvm-config-3.3 --cppflags --ldflags --libs core jit native` -ly -ll 
/bin/sh: llvm-config-3.3: command not found 
In file included from expr-codegen.y:6: 
./decafdefs.h:5:10: fatal error: 'llvm/IR/DerivedTypes.h' file not found 
#include "llvm/IR/DerivedTypes.h" 
     ^
1 error generated. 
In file included from expr-codegen.lex:2: 
./decafdefs.h:5:10: fatal error: 'llvm/IR/DerivedTypes.h' file not found 
#include "llvm/IR/DerivedTypes.h" 
     ^
1 error generated. 
make: *** [expr-codegen] Error 1 

這裏是我的makefile:

lexlib=l 
yacclib=y 
bindir=. 
rm=/bin/rm -f 
mv=/bin/mv -f 
targets= 
#cpptargets=type-inherit decaf-sym 
#llvmtargets=factorial 
#llvmcpp=sexpr2-codegen expr-codegen 
#llvmfiles=rec_add 
#llvmcpp=decaf-sym expr-codegen sexpr2-codegen 
llvmcpp=expr-codegen 

all: $(targets) $(cpptargets) $(llvmfiles) $(llvmcpp) 

$(targets): %: %.y 
    @echo "compiling yacc file:" $< 
    @echo "output file:" [email protected] 
    bison [email protected] -d $< 
    flex [email protected] [email protected] 
    clang -o $(bindir)/[email protected] [email protected] [email protected] -l$(yacclib) -l$(lexlib) 
    $(rm) [email protected] [email protected] [email protected] 

$(cpptargets): %: %.y 
    @echo "compiling cpp yacc file:" $< 
    @echo "output file:" [email protected] 
    bison -b [email protected] -d $< 
    $(mv) [email protected] [email protected] 
    flex [email protected] [email protected] 
    clang++ -o $(bindir)/[email protected] [email protected] [email protected] -l$(yacclib) -l$(lexlib) 
    $(rm) [email protected] [email protected] [email protected] 

$(llvmcpp): %: %.y 
    @echo "compiling cpp yacc file:" $< 
    @echo "output file:" [email protected] 
    bison -b [email protected] -d $< 
    $(mv) [email protected] [email protected] 
    flex [email protected] [email protected] 
    clang -g -c decaf-stdlib.c 
    clang++ -o $(bindir)/[email protected] [email protected] [email protected] decaf-stdlib.o `llvm-config-3.3 --cppflags --ldflags --libs core jit native` -l$(yacclib) -l$(lexlib) 
    $(rm) [email protected] [email protected] [email protected] 

$(llvmtargets): %: %.ll 
    @echo "using llvm to compile file:" $< 
    llvm-as $< 
    `llvm-config-3.3 --bindir`/llc -disable-cfi [email protected] 
    clang [email protected] ../decaf-stdlib.c -o $(bindir)/[email protected] 

$(llvmfiles): %: %.ll 
    @echo "using llvm to compile file:" $< 
    llvm-as $< 
    `llvm-config-3.3 --bindir`/llc -disable-cfi [email protected] 
    clang [email protected] decaf-stdlib.c -o $(bindir)/[email protected] 

clean: 
    $(rm) $(targets) $(cpptargets) $(llvmtargets) $(llvmcpp) $(llvmfiles) 
    $(rm) *.tab.h *.tab.c *.lex.c 
    $(rm) *.bc *.s *.o 
    $(rm) -r *.dSYM 

作爲一個總的新手到LLVM我不知道爲什麼我可以」讓編譯器識別LLVM並使用它。任何幫助,將不勝感激。謝謝。

+0

你很可能需要告訴編譯器的頭文件。看看'-I'標誌。 – Leandros

回答

1

從LLVM-配置文件:

dzur:~/tmp> llvm-config 
usage: llvm-config <OPTION>... [<COMPONENT>...] 

Get various configuration information needed to compile programs which use 
LLVM. Typically called from 'configure' scripts. Examples: 
    llvm-config --cxxflags 
    llvm-config --ldflags 
    llvm-config --libs engine bcreader scalaropts 

,這是相當多的,你需要什麼:)