Reputation: 595
I installed LLVM with brew
brew install llvm
in a test c++ file:
#include <llvm/IR/Value.h>
#include <llvm/IR/IRBuilder.h>
int main()
{
llvm::LLVMContext context;
llvm::Module *module = new llvm::Module("module", context);
return 0;
}
Makefile:
BIN=main
SRC_FILES=main.cpp
FLAGS := $(shell llvm-config --cxxflags --ldflags --libs)
CC=/usr/local/opt/llvm/bin/clang
CXX=$(CC)++
all:
$(CXX) $(FLAGS) -o $(BIN) $(SRC_FILES)
When I run make
It gives me this error:
Undefined symbols for architecture x86_64:
"_del_curterm", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libLLVMSupport.a(Process.cpp.o)
"_set_curterm", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libLLVMSupport.a(Process.cpp.o)
"_setupterm", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libLLVMSupport.a(Process.cpp.o)
"_tigetnum", referenced from:
llvm::sys::Process::FileDescriptorHasColors(int) in libLLVMSupport.a(Process.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
What am I doing wrong here?
Upvotes: 1
Views: 362
Reputation: 595
I ended up needing --system-libs
as a flag in the llvm-config
command:
FLAGS := $(shell llvm-config --cxxflags --ldflags --libs --system-libs)
Upvotes: 3