[LLVMdev] Build a static-linked executable using llvm

汶翰 (Wen-Han) nowar100 at gmail.com
Fri Jan 7 22:16:32 PST 2011


Hello all,

I wanna build a static linked executable using llvm. But I failed.
My question is Can we use -static using llvm?

Thanks for any response.

Below is details
========
First I use

  $ clang++ test.cc `llvm-config --cxxflags --ldflags --libs`

I works as usual.  But if I use

  $ clang++ test.cc `llvm-config --cxxflags --ldflags --libs` -static

It yells lots of undefined reference, like this

/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__deregister_frame_info_bases':
(.text+0x1a16): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__register_frame_info_bases':
(.text+0x61): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libgcc_eh.a(unwind-dw2-fde-glibc.o): In
function `__register_frame_info_table_bases':
(.text+0xfa): undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
clang: error: linker (via gcc) command failed with exit code 1 (use -v to
see invocation)

But in directory <llvm>/lib, I see many libxxx.a.
I think they just have lots of xxx.o archive.
Why cannot these xxx.o build with -static?

Thank you.

-- 
Best regards,
Wen-Han (Nowar)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110108/e100d6d8/attachment.html>


More information about the llvm-dev mailing list