0

I've recently started to cross compile a couple of C applications for Android. I've successfully done this for image conversion software using the following pseudo-instructions:

  • Build the Android toolchain
  • Compile Automake and Autoconf
  • Set the CC and CXX environment variables
  • Build the source package (delete configure, configure.sub, configure.guess, run autoconf configure.ac > configure, run configure with CFLAGS using arm-linux-androideabi, make and make install)

I am now trying to do this for an OCR library written in C. The problem that I am running into is that the library has no configure, configure.guess, or configure.sub. It only has a makefile.

I am not too familiar with C, but is there any different process that I should be following in this situation?

The ./configure step:

CFLAGS=’-march=armv7-a –mfloat-abi=softfp’ ./configure –prefix=/home/user/Downloads/install/usr/local –host=arm-eabi –enable-shared=no –with-modules --enable-delegate-build
littleK
  • 19,521
  • 30
  • 128
  • 188

2 Answers2

0

According to this article: What does a typical ./configure do in Linux?

configure only checks for system dependencies (if they are missing it exits), checks the type of system you are on, adn then creates a makefile. since you already have a makefile, you should already be able to execute make install.

Community
  • 1
  • 1
KrisSodroski
  • 2,796
  • 3
  • 24
  • 39
  • I just don't understand how the library is cross-compiled then. It seems like the ./configure step (see my updated post) is the necessary step... – littleK May 15 '13 at 13:23
  • ./configure makes hte make file. when you specify a target, all this does is put a directive in make install that tell its which compiler to use. You can manually add this directive and get the same result: http://stackoverflow.com/questions/3090224/how-to-instruct-makefile-to-use-different-compilers – KrisSodroski May 15 '13 at 13:26
0

is there any different process that I should be following in this situation?

Not really. I mean, if you plan to work with the Android Standalone Toolchain, then all you need to do is:

  1. create the toolchain with the ad hoc target, e.g --platform=android-9
  2. add the toolchain directory to the PATH (for convenience)
  3. export the sysroot path, e.g. export SYSROOT=/tmp/my-android-toolchain/sysroot (for convenience)
  4. set your C compiler (export CC="arm-linux-androideabi-gcc --sysroot $SYSROOT") and archiver, if you target a static library (export AR=arm-linux-androideabi-ar)

Then it all depends about how your Makefile has been written, i.e what are the targets? influential environment variables? etc. But in practice, if the default target fits your need, all you need to do is to run make while overriding the C flags to set the target architecture (ARMv7 here):

make CFLAGS="-march=armv7-a"

That's it. Repeat with other archs (armeabi, x86, etc) if needed.


You can see a complete example for jsmn - a lightweight JSON parse written in C, here: http://git.io/ndk-jsmn.

I've also a set of slides that cover this topic that you may find useful.

deltheil
  • 15,496
  • 2
  • 44
  • 64