Static Linking and loading ""


I’ve compiled llvm/clang with arm-linux-gnueabi toolchain:

rm -rf $BUILD
mkdir $BUILD

cmake …/llvm_33 -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_CROSSCOMPILING=True -DLLVM_TABLEGEN=/home/asmirnov/llvm_33_build/Release+Asserts/bin/llvm-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabi -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=Release

When i try to load library on android (linux), i’m getting an error:

Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 185 could not load needed library ‘’ for ‘’ (load_library[1093]: Library ‘’ not found)

The sources are extracted for clang release 3.3 (llvm, compiler-rt and clang). The build type is “Release”. So what should i do in order to link it statically (or walk-around lib absence)?

PS. “” file size is about 14mb.

Regards, Anton.

The same problem if i recompile is in Debug mode and is about 48Mb.

Any thoughts?

Hi Anton,

libdl is required (as others) and probably not installed in your target
system. You should be able to install it via yum/apt-get etc.

Installing Clang via packages would probably bring that dependency
automatically, but you compiled it from scratch on a separate machine, so
dependencies won't be met automatically.

And, yes, Clang/LLVM libraries are huge, especially ones with debug symbols
in it.


As target system is Android i can’t just add packages without rooting which is not desired.
That’s why i’d like to link libclang statically in order to have all dependencies within .so.

Is it possible?

I’ve found /system/lib/ on my android device. So i wonder why it’s not found and loaded.
Does the fact that i’m compiling on linux 64bit but it’s running on linux 32bit (android) affect this?

I've found /system/lib/ on my android device. So i wonder why it's
not found and loaded.

That's a good question. I'm not familiar with Android, so I can't answer
that. Maybe you'll have more luck on an Android forum?

Does the fact that i'm compiling on linux 64bit but it's running on linux
32bit (android) affect this?

It shouldn't.



Note that there may be a slightly different issue: to my understanding Android actually provides a lot of the system calls expected of a Unix-y environment, but often puts them in different libraries. (At the very least, it looks like the linker is looking directly for, which may not be the version used on Android, or as mentioned the functionality LLVM wants may actually be resident in a different .so file). However, I’m not remotely expert of the intricacies of Android, so I’ll leave further advice for someone who’s actually built LLVM for Android J (In the worst case that no-one has done this you may have to figure out the dependencies and change the LLVM build-files yourself.)