I’ve compiled llvm/clang with arm-linux-gnueabi toolchain:
rm -rf $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 libclang.so.3.3 on android (linux), i’m getting an error:
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image: 185 could not load needed library ‘libdl.so.2’ for ‘libclang.so.3.3’ (load_library: Library ‘libdl.so.2’ 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. “libclang.so.3.3” file size is about 14mb.
The same problem if i recompile is in Debug mode and libclang.so is about 48Mb.
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
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/libdl.so 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/libdl.so 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?
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 libdl.so.2, 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.)