c++rubylinkerclangswig

linking clang lib allways undefined symbol


I have created an some classes I want to use with swig in order to generate ruby binding. Everything is ok when I generate the code or compile the ruby module. But when a script load this module, there is an error:

undefined symbol: _ZTVN5clang5LexerE 

I understand that this means that the problem is for the clang::Lexer. But I know I have set the lclangLex lib for this.

here is the command I use in order to link the objects files:

clang++ -shared -o parser.so parser.o Declarations.o -L. -L/usr/lib -L. -Wl,-O1,\
--sort-common,--as-needed,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic \
-L/usr/lib  -lz -lpthread -lffi -lcurses -ldl -lm     -lruby -lclangLex -lclangAST \ 
-lpthread -lgmp -ldl -lcrypt -lm   -lc -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo \
-lLLVMTarget -lLLVMCore -lLLVMMC -lLLVMObject -lLLVMSupport

any idea ?


Solution

  • The problem was the order of the libs given to the linker:

    -lclangAST -lclangLex -lclangBasic 
    

    lclangAST must be given before lclangLex then I just had to add lclangBasic and everything works.