Steps For Porting JSON-C For Android

Link of Ported code:
I have already ported the code for JSON-C. Can be found in the location: JSON-C For Android

Development machine used:
Ubuntu 12.04 (LTS) - x86_64
NDK - r9d

Required tools for compiling the JSON-C Code:
1. autoconf - http://www.gnu.org/software/autoconf/
2. androgenizer - http://cgit.collabora.com/git/user/derek/androgenizer.git/

Building the "autoconf":
1. git clone git://git.sv.gnu.org/autoconf
2. cd to autoconf directory
3. Try executing command "autoconf"
    a. If you don't have any previous version of autoconf, then better to download binary version.
    b. If you have already have old version of autoconf, then try building from the above mentioned source code.
4. Add the bin path the "$PATH" in the "~/.bashrc" file.
5. Re-source the "~/.bashrc" file.

Building the "androgenizer":
1. git clone https://github.com/qdii/androgenizer.git
2. Execute "autoconf"
    a. If you get any errors try "autoreconf -fi"
3. Follow recommendations in the output of above command.
    a. Like "Consider adding....."
4. Run "make"
5. Run "make install (or) sudo make install"

Building the JSON-C Code:
1. git clone https://github.com/json-c/json-c.git
2. cd json-c
3. ./autogen.sh os=-linux-android
    a. If you get any errors like below, do the same.
        libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
        libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
        libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
    b. Vim configure.ac
        Add “AC_CONFIG_MACRO_DIR([m4])” after  “AC_PREREQ(2.52)”.
    c. Vim Makefile.am.inc
        Add at the end “ACLOCAL_AMFLAGS = -I m4”
4. libtoolize –force
5. make Android.mk
6. touch AndroidManifest.xml
    This is an empty file, but still is required.
7. Create an "Applictaion.mk" file in the "json-c" directory with below contents.
APP_BUILD_SCRIPT := Android.mk
APP_MODULES := libjson-c
#android-9 - Official Android 2.3 system images
APP_PLATFORM := android-9
APP_OPTIM := release
APP_STL := gnustl_shared
APP_GNUSTL_CPP_FEATURES := exceptions rtti 
APP_ABI := armeabi armeabi-v7a x86 



8. ndk-build NDK_APPLICATION_MK=`pwd`/Application.mk

After executing the 8th step. "libs" & "obj" folders will be created in the "json-c" folder.

FAQ:
Please find below issues I faced during compilation.

test@ubuntu:~/VPN$ cd json-c/
test@ubuntu:~/json-c$ autoconf
configure.ac:6: error: possibly undefined macro: AM_INIT_AUTOMAKE
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:29: error: possibly undefined macro: AM_PROG_CC_C_O
configure.ac:71: error: possibly undefined macro: AM_PROG_LIBTOOL
test@ubuntu:~/json-c$ autoreconf -fi
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.ac and
libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
configure.ac:29: installing `./compile'
configure.ac:43: installing `./config.guess'
configure.ac:43: installing `./config.sub'
configure.ac:6: installing `./install-sh'
configure.ac:6: installing `./missing'
tests/Makefile.am: installing `./depcomp'
Makefile.am: installing `./INSTALL'
test@ubuntu:~/json-c$


2 comments:

Suman said...

https://stackoverflow.com/questions/23239674/compiliing-json-c-for-android-using-androgenizer/25759419#25759419

Unknown said...

Thank you for sharing run C/C++ program on Android