LLVM-3.1 libLLVMSupport.a undefined reference to `dladdr'
- by user91387
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?