2
votes

I need to build a static library from the latest libpcap and "include" it in a C source code to be cross-compiled for an ARM-v7-a architecture (Nexus One).

I've been trying for days, hope someone could give me an hint.

And I can't use neither NDK nor Java-wrapper functions. It needs to be like:

$ -o prog prog.c [-options] and later I'll be able to push the executable via adb.

I've tried with CodeSourcery and arm-linux-gnueabi installed via apt-get (i'm on Kubuntu Linux), nothing worked properly.

The most I've reached to achieve is a stupid simply helloworld file through:

arm-linux-gnueabi-gcc -static -o prog prog.c

which is executed under my smartphone.

Do you have any clue about I can get a more complex program including libpcap? I think it should deal with .a or .so files in libpcap directory but I really don't figure it out... Thanks in advance

EDIT - SOLVED: Just as auselen said, I've tried with NDK stand-alone toolchain and I've succeded.

This is what I've done, in case somebody would have my same issues:

1) Download Android SDK and NDK (the latter is at r8d version at this time)

2) Go into NDK folder and type

cd build/tools

make-standalone-toolchain.sh --platform=android-3 --install-dir=$HOME/new_toolchain --ndk-dir=YOUR_NDK_PATH

cd $HOME/new_toolchain

(I've put my helloworld.c file in this folder but of course you can add PATH into your .bashrc file for more efficiency)

bin/arm-linux-androideabi-gcc helloworld.c -o helloworld

3)push it into your device through adb.

All is working now :) thanks again

1

1 Answers

2
votes

Since Android uses a different runtime (bionic) it is still best to use NDK which has the necessary components to link your application accordingly.

NDK allows you to run it as a standalone toolchain, so you can directly initiate gcc via its sysroot feature.

An important tip is to not use ~ in those paths specified when invoking gcc, it isn't that friendly.