Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I link to LLVM libraries?

Tags:

llvm

clang

When I use command "gcc .. ../../*.so", there are the following error messages:

/usr/bin/ld: /home/demonwnb/build/src/*.so: error: undefined reference to 'llvm::raw_ostream::operator<<(void const*)'
/usr/bin/ld: /home/demonwnb/build/src/*.so: error: undefined reference to 'clang::DeclarationName::printName(llvm::raw_ostream&) const'

I think that I do not link "llvm library" correctly, so how should I do?

like image 493
kunou Avatar asked Sep 10 '25 20:09

kunou


1 Answers

You need to tell your compiler where to load the libraries from, which can be done using the llvm-config command.

You could set the following symbols in your makefile

CC = g++

LLVM_MODULES = core jit native

CPPFLAGS = `llvm-config --cppflags $(LLVM_MODULES)`
LDFLAGS = `llvm-config --ldflags $(LLVM_MODULES)`
LIBS = `llvm-config --libs $(LLVM_MODULES)`

all:
    $(CC) *.o $(LDFLAGS) $(LIBS) -o MyOutput
main:
    find -name '*.cpp' -print0 | xargs -0 $(CC) -c $(CPPFLAGS)
like image 93
Chethan Ravindranath Avatar answered Sep 16 '25 09:09

Chethan Ravindranath