2

I'm trying to compile using the llvm-3.1 package. I'm running 12.04 x64 (3.2.0-26 kernel) && 12.10 (3.5.0-4) x64 backported llvm-3.1 from quantal, then debian experimental.
Next I tried 12.10 with the native ubuntu llvm-3.1 package; this failed as well.

user@system:/tmp/llvm-test# make  
compiling cpp yacc file: decaf-llvm.y  
output file: decaf-llvm  
bison -b decaf-llvm -d decaf-llvm.y  
/bin/mv -f decaf-llvm.tab.c decaf-llvm.tab.cc  
flex -odecaf-llvm.lex.cc decaf-llvm.lex  
g++ -o ./decaf-llvm decaf-llvm.tab.cc decaf-llvm.lex.cc decaf-stdlib.c `llvm-config --cppflags --ldflags --libs core jit native` -ly -ll  
/usr/lib/llvm-3.1/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x6c): undefined reference to `dladdr'  
/usr/lib/llvm-3.1/lib/libLLVMSupport.a(Signals.o): In function `PrintStackTrace(void*)':
(.text+0x18f): undefined reference to `dladdr'  
collect2: error: ld returned 1 exit status  
make: *** [decaf-llvm] Error 1  

I know the code works as I've run it in centos fine using llvm-3.1-6.fc18(rpm)

Google was a bit helpful with this:

"On some systems, incluning Ubuntu 11.10, linking may fail with message that libLLVMSupport.a in function PrintStackTrace(void*) has undefined reference to dladdr."

"Workaround is to compile LLVM with cmake specifying the following variable: -DCMAKE_EXE_LINKER_FLAGS=-ldl"

http://svn.dsource.org/projects/bindings/trunk/llvm-3.0/Readme

I double checked y ldflags and everything seems ok.

user@system:/llvm-config --ldflags
-L/usr/lib/llvm-3.1/lib  -lpthread -lffi -ldl -lm

I'm unclear of what to do next; any suggestions?

3

I asked (and answered) a similar question on Stack Overflow. Adapting my answer from that question to yours:

The library requiring the symbols is included by -lLLVMSupport, so -ldl must come after -lLLVMSupport. See Why does the order of '-l' option in gcc matter? on Stack Overflow. You need to change this:

`llvm-config --cppflags --ldflags --libs core jit native`

To this:

`llvm-config --cppflags --libs core jit native` `llvm-config --ldflags`

And the linker should be successful. Let me know if you find a better solution to fix the order of --ldflags.

-1
sudo apt-get install libx11-xcb-dev llvm-dev x11proto-gl-dev x11proto-dri2-dev libxext-dev libxdamage-dev libxfixes-dev libxcb-glx0 libxcb-glx0-dev libpng12-dev
  • 4
    Welcome to Ask Ubuntu! This answer would benefit substantially, if you were to edit it to add some explanation (or at least to tell the user exactly what to do with these lines). – Eliah Kagan Oct 20 '12 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.