I am currently compiling Android Linaro build 11.11 (staging-panda) for pandaboard.
In the build process, Android compiles some tools with the host gcc compiler. On my Linux Mint 12 (Ubuntu-11.10 based), I have gcc-4.6 installed by default.
I built Android, everything runs fine, pandaboard booted, but then starting any application will lead to segmentation fault (signal 11 in logcat).
I then learned that Linaro built this release with gcc-4.5, not 4.6 version. I installed it using apt-get. I removed out/ directory and rebuild Android entirely.
The compilation runs fine, but the linker insults me:
g++-4.5 -Wl,-rpath-link=out/target/product/pandaboard/obj/lib -Wl,-rpath,\$ORIGIN/../lib -Lout/host/linux-x86/obj/lib -Wl,--no-undefined -m32 out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o -Wl,--whole-archive -Wl,--no-whole-archive out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a -o out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp
g++-4.5 -Wl,-rpath-link=out/target/product/pandaboard/obj/lib -Wl,-rpath,\$ORIGIN/../lib -Lout/host/linux-x86/obj/lib -Wl,--no-undefined -m32 out/host/linux-x86/obj/EXECUTABLES/mkbootfs_intermediates/mkbootfs.o -Wl,--whole-archive -Wl,--no-whole-archive -o out/host/linux-x86/obj/EXECUTABLES/mkbootfs_intermediates/mkbootfs
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned 1 exit status
The linker grabs the 64bit libraries of gcc-4.5, although it probably for 32bit version. So far, here are the things I tried, without success:
re-do the package installation following these instructions
sudo ldconfig
reboot my machine
I looked into removing gcc-4.6 to get only gcc-4.5 on my machine.
But synaptic showed so many dependencies needed to be uninstalled,
that I didn't make that step :)
Finally I've been told to install gcc-4.5-multilib and g++-4.5-multilib. It worked, and the build got further. I start the panda, still the apps (eg com.android.launcher) fails to launch. I know this is an assumption, but I think that this segfault is somehow linked to the compiler.
My questions are simple:
Is com.android.launcher cross-compiled or compiled with host 32bit
compiler? What keyword should I look for to find the associated command in the build log?
How can I debug this segmentation fault? In particular, I am looking
for starting com.android.launcher with the "am" command.
Will strace provide valuable information for this issue?
Thanks heaps.
Use gdb. Requirements:
# is the target shell, although being root is not mandatory
$ is the host shell
The app must be compiled in debug mode
LOCAL_CFLAGS += -g
start gdbserver on the target:
# gdbserver :5039 </system/bin/executable>
(or)
# gdbserver :5039 --attach <pid>
forward tcp port to adb connection:
$ adb forward tcp:5039 tcp:5039
start gdbclient on the host:
$ gdbclient :5039 <executable>
If you struggle with gdbclient, check build/envsetup.sh where the function is defined: $ type gdbclient Adding the verbose -v option might be of some help. Also if your executable is not in system/bin, you'll definitely need to modify build/envsetup.sh as it is hard-coded.
Some more information can be found here.
Related
I became interested in the Android's source code. I precisely repeated all the steps from the official guide source.android.com to compile it.
I tried to compile it and I got:
... error while loading shared libraries: libncurses.so.5: cannot open shared
object file: No such file or directory
To fix it:
Arch: Enable multilib,sudo pacman -S lib32-ncurses
Ubuntu: sudo apt install libncurses5:i386
Then i tried to compile again
Next time i got no errors messages except exit status 1
[100% 1/1] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
FAILED: out/soong/build.ninja
out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b
out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build
-globs.ninja -o out/soong/build.ninja Android.bp
21:03:08 soong bootstrap failed with: exit status 1
#### failed to build some targets (24:14 (mm:ss)) ####
When there are no error messages, I can't guess what's the matter
But i know, what:
This error is independent of linux distribution
Deleting and downloading all sources again cannot fix this error
Before I get this error, my computer freezes
It seems that your ninja process is getting killed. That's probably because it tries to use too much RAM: we currently allow ~3.5GB RAM per workspace, so the Linux OOM-killer will kill any process that makes your workspace use more than that.
In order to use less RAM, could you please try building with fewer processes? E.g. with:
$ make -j2 aapt
I want to port libimobiledevice to android with ndk in order to make android device enable to communicate with iphone, and import data from iphone to android device. i found this project use autoconf. so i made cross compile use following command
./configure --build=x86_64-pc-linux-gnu --host=arm-linux-androideabi --target=arm-linux-androideabi CPPFLAGS="-I$ANDROID_NDK/platforms/android-14/arch-arm/usr/include -I$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/include -I$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -I$ANDROID_NDK/sources/crystax/include" CFLAGS="-nostdlib" LDFLAGS="-Wl,-rpath-link=$ANDROID_NDK/platforms/android-14/arch-arm/usr/lib -L$ANDROID_NDK/platforms/android-14/arch-arm/usr/lib" LIBS="-lc"
but run into some error, can't find pthread python.
checking for pthread_create, pthread_mutex_lock in -lpthread... no
configure: error: libpthread is required to build libimobiledevice
checking for a version of Python >= '2.1.0'... yes
checking for the distutils Python package... yes
checking for Python include path... -I/usr/include/python2.7
checking for Python library path... -L/usr/lib/python2.7 -lpython2.7
checking for Python site-packages path... /usr/lib/python2.7/site-packages
checking python extra libraries... -ldl
checking python extra linking flags...
checking consistency of all components of python development environment... no
configure: error:
Could not link test program to Python. Maybe the main Python library has been
installed in some non-standard library path. If so, pass it to configure,
via the LDFLAGS environment variable.
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
============================================================================
ERROR!
You probably have to install the development version of the Python package
for your distribution. The exact name of this package varies among them.
============================================================================
I am trying to debug a C++ native code on Android device using NDK.
The Android.mk already has the debug flags:
APP_OPTIM:= debug
LOCAL_CFLAGS := -DRAPIDXML_NO_EXCEPTIONS
LOCAL_CFLAGS += -g
LOCAL_CFLAGS += -ggdb
LOCAL_CFLAGS += -O1
I also tried with the flag -O0 instead of -O1.
And the AndroidManifest.xml has also the debug mode:
android:debuggable="true"
So, here we go... I put some breakpoints in the code to watch it step by step. Went to the terminal and typed:
$ adb shell ps |grep packtpub
app_57 24084 117 467368 49136 ffffffff 00000000 S com.packtpub.app3D
Then run the debug:
$ ndk-gdb --verbose --force
...
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /home/android-sdks/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.packtpub.app3D/debug-socket
## COMMAND: /home/android-sdks/platform-tools/adb shell run-as com.packtpub.app3D lib/gdbserver +debug-socket --attach 1822
## COMMAND: /home/android-sdks/platform-tools/adb pull /system/bin/app_process ./obj/local/armeabi/app_process
Attached; pid = 1822
Listening on sockaddr socket debug-socket
Pulled app_process from device/emulator.
## COMMAND: /home/android-sdks/platform-tools/adb pull /system/lib/libc.so ./obj/local/armeabi/libc.so
Pulled libc.so from device/emulator.
The application starts and run. But no break points show up. Neither the (gdb) prompt appears to allow me to set commands.
I tried both ways: from Eclipse IDE, and from console using the command line. And the same happens.
Any suggestion how to spot what is missing to put the debug on and have the breakpoints working?
All comments and suggestions are highly appreciated.
So... I keep fighting to solve why the ndk-debug is not running. Maybe I came across something that can shed a little light on it:
I have also added to Android.mk:
APP_MODULES := callbacks
APP_PLATFORM := android-14
On command line in the terminal:
$ android update project -p . --target android-14
It gives the message:
Error: Target id 'android-14' is not valid. Use 'android list targets' to get the target ids.
Then we obtain the output when running the list targets:
$ android list targets
id: 1 or "android-15"
Name: Android 4.0.3
Type: Platform
API level: 15
...
id: 2 or "Google Inc.:Google APIs:15"
On the other hand it compiles and builds on command line only if I put 'android-15', but it will not run in the device (a Samsung Nexus), which has the 'android-14'. In the AndroidManifest.xml it was setup as 14, to allow the App to compile, load and run in the device from the Eclipse IDE:
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="14">
In Eclipse IDE it compiles and runs with no complaints as Android-14. When asked to run ndk-debug on Eclipse IDE, it also doesn't complaint as shown mentioned in my previous post, but neither the (gdb) appears.
However, when I try to run the ndk-debug on command line it complains and shows that it is not attaching the debugger:
$ ndk-gdb --verbose --force
...
Launched gdbserver successfully.
## COMMAND: /home/android-sdks/platform-tools/adb shell run-as com.packtpub.app3D lib/gdbserver +debug-socket --attach 7722
## COMMAND: /home/android-sdks/platform-tools/adb pull /system/bin/app_process ./obj/local/armeabi/app_process
Cannot attach to process 7722: Operation not permitted (1)
Pulled app_process from device/emulator.
The ndk-gdb not working has something to do with the target version?
Any suggestions or workaround that might fix it and make possible to have active breakpoint to debug NDK?
Thanks in advance.
Solved the problem installing the API 14 in the debugging environment,and creating a new project entirely as API 14. Now it works.
Hi I have got a problem that I can't solve when compiling the android source for ICS. The build gets to a certain stage, then I get the message:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../libtinfo.so when searching for -ltinfo
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../libtinfo.a when searching for -ltinfo
/usr/bin/ld: skipping incompatible /usr/lib/libtinfo.so when searching for -ltinfo
/usr/bin/ld: skipping incompatible /usr/lib/libtinfo.a when searching for -ltinfo
/usr/bin/ld: cannot find -ltinfo
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
make: *** Waiting for unfinished jobs....
I have tried updating/installing libncurses5-dev and libtinfo-dev which were both latest versions and am a bit stuck now. How can I get rid of this to allow the build to happen properly?
I had seen similar issue with gingerbread when compiled on 64bit ubuntu. It got fixed with installation of lib32ncurses5-dev and its dependencies which includes lib32tinfo5-dev. The compiled host adb executable with android is a 32-bit executable.
I have seen same problem on my fedora 16 64bit, same android branch 4.0.3 r1
you might want to try ncurses-devel.i686
yum install ncurses-devel.i686
it solved my problem
I got this issue while I was building mysql statically. So I had to install the static versions of these libraries. For example I did run:
yum search ncurses
Then I installed,
yum install ncurses-static # not exactly the same syntax, but something similar; see search command's output
This might work in Fedora 23
dnf install ncurses-devel
I followed instructions from here. After $ repo sync I tried to build it with $ make, but got this error:
host SharedLib: libneo_cgi (out/host/linux-x86/obj/lib/libneo_cgi.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.a when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_cgi.so] Error 1
Using Ubuntu 10.04 LTS. Any help appreciated.
UPD: I found a discussion, that claims, that problem could be that I'm having 64bit libs on my 32bit system.
$ ls -l /usr/lib/libz.so
lrwxrwxrwx 1 root root 20 2010-07-07 17:08 /usr/lib/libz.so -> /lib/libz.so.1.2.3.3
$ file /lib/libz.so.1.2.3.3
/lib/libz.so.1.2.3.3: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
How do I figure out, if that libz.so.1.2.3.3 is the right lib, and in case I have to replace it with the right one, how do I do it?
Also, $ arch says, I have an i686 architecture. Machine, I'm using is Lenovo ThinkPad SL500 with Core 2 DUO CPU.
Everything works now, the solution was to install lib64z1-dev:
sudo apt-get install lib64z1-dev
Edit: now there's another problem, with ClearSilver, described here and finally resolved here.
You need to install libz.
sudo apt-get install libz-dev
libz library has different name in different distros
lib32z1 on debian system