Here are my notes how to compile libopenbabel for Android platform.
Perhaps they would of interest to somebody, maybe even added to a Wiki
somewhere?

1. You will need Android SDK and a modified NDK which supports RTTI,
STL, and exceptions. You can get the modified NDK here:
http://www.crystax.net/android/ndk-r4.php

2. Android runs Java programs, libopenbabel provides C++ API. In order
to connect the two you will need to write JNI C++ wrapper. Programming
for Android with and without JNI is described in detail elsewhere,
please be aware that there will be quite a few things to do even after
libopenbabel is compiled. Create the Java project first, even if it is
empty for the moment.

3. Unzip openbabel source. You might have to patch file src/local.cpp,
the patch was submitted here:
http://openbabel.svn.sourceforge.net/viewvc/openbabel?view=revision&revision=4050
(should be included in 2.3.0 release)

4. Put the attached babelconfig.h into include/openbabel.

5. Copy InChI headers: from include/inchi102/*.h to
src/formats/inchi102/

6. Create directory jni in top level openbabel source folder and put
attached Android.mk and Application.mk there.

7. Edit Application.mk to modify the locations in
APP_PROJECT_PATH (should point to your Java Android project)
and APP_BUILD_SCRIPT (should point to the aforementioned Android.mk
script). You can also uncomment APP_ABI line to have both armeabi and
armeabi-v7a executables. The latter allows for floating point unit on
the target device.

8. Edit Android.mk if you'd like to have access to more formats - by
default I included only SMILES and InChI. It should be trivial to
include more formats. Note that I had problems with reaction formats,
such as rsmilesformat, those that include reaction.h header. Avoid those
unless necessary, otherwise you're on your own.

9. Run ndk-build script from the NDK you downloaded in step 1. It will
compile libopenbabel.so and put it into your Android Java project
directory. Remember that you will have to load libopenbabel.so in your
Java program prior to any other C++ code which will use OpenBabel
functions.

Have fun!
Igor Filippov



/* src/config.h.  Generated from config.h.in by configure.  */
/* src/config.h.in.  Generated from configure.in by autoheader.  */

/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */

/* Used by other #define statements for symbol exporting
 Use symbol hiding in GCC 4.0 and later where available */
#ifdef HAVE_GCC_VISIBILITY
  #define OB_EXPORT __attribute__ ((visibility("default")))
  #define OB_IMPORT __attribute__ ((visibility("default")))
  #define OB_HIDDEN __attribute__ ((visibility("hidden")))
#elif defined(WIN32)
  #define OB_EXPORT __declspec(dllexport)
  #define OB_IMPORT __declspec(dllimport)
  #define OB_HIDDEN
#else
  #define OB_EXPORT
  #define OB_IMPORT
  #define OB_HIDDEN
#endif


/* Where the data files are located */
#define BABEL_DATADIR "/home/igor/arm/install/share/openbabel"

/* The version of Open Babel */
#define BABEL_VERSION "2.2.3"

/* Used to export symbols for DLL / shared library builds */
#if defined(USING_OBDLL) // e.g. in src/main.cpp
  #define EXTERN OB_IMPORT extern
#else
  #define EXTERN OB_EXPORT extern
#endif


/* define if the Boost library is available */
#define HAVE_BOOST /**/

/* Define to 1 if the system has the type `clock_t'. */
#define HAVE_CLOCK_T 1

/* Define to 1 if you have the <conio.h> header file. */
/* #undef HAVE_CONIO_H */

/* Define to 1 if you have the <ctype.h> header file. */
#define HAVE_CTYPE_H 1

/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */

/* Define to 1 if you have the <fstream> header file. */
#define HAVE_FSTREAM 1

/* Define to 1 if you have the <fstream.h> header file. */
/* #undef HAVE_FSTREAM_H */

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <iostream> header file. */
#define HAVE_IOSTREAM 1

/* Define to 1 if you have the <iostream.h> header file. */
/* #undef HAVE_IOSTREAM_H */

/* Define to 1 if you have the `m' library (-lm). */
#define HAVE_LIBM 1

/* Define to 1 if you have the `z' library (-lz). */
/* #undef HAVE_LIBZ */

/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1

/* Define to 1 if you have the <math.h> header file. */
#define HAVE_MATH_H 1

/* Define to 1 if you have the <memory.h> header file. */
/* #undef HAVE_MEMORY_H */

/* Define to 1 if you have the <regex.h> header file. */
#define HAVE_REGEX_H 1

/* Define to 1 if you have the `rint' function. */
#define HAVE_RINT 1

/* Define to 1 if you have the <rpc/types.h> header file. */
/* #undef HAVE_RPC_TYPES_H */

/* Define to 1 if you have the <rpc/xdr.h> header file. */
/* #undef HAVE_RPC_XDR_H */

/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1

/* Define to 1 if you have the `sranddev' function. */
/* #undef HAVE_SRANDDEV */

/* Define to 1 if you have the <sstream> header file. */
#define HAVE_SSTREAM 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
/* #undef HAVE_STRINGS_H */

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the `strncasecmp' function. */
#define HAVE_STRNCASECMP 1

/* Define to 1 if you have the <strstream> header file. */
#define HAVE_STRSTREAM 1

/* Define to 1 if you have the <strstream.h> header file. */
/* #undef HAVE_STRSTREAM_H */

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1

/* Define to 1 if you have the <tr1/memory> header file. */
#define HAVE_TR1_MEMORY 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to 1 if you have the `uselocale' function. */
/* #undef HAVE_USELOCALE */

/* Define to 1 if you have the <xlocale.h> header file. */
/* #undef HAVE_XLOCALE_H */

/* Define to the sub-directory in which libtool stores uninstalled libraries.
   */
#define LT_OBJDIR ".libs/"

/* The file extension used for shared modules */
#define MODULE_EXTENSION ".so"

/* Used to export symbols for DLL / shared library builds */
#if defined(USING_OBDLL) // e.g. in src/main.cpp
  #define OBAPI OB_IMPORT
#else
  #define OBAPI OB_EXPORT
#endif


/* Used to export symbols for DLL / shared library builds */
#if defined(USING_OBDLL) // e.g. in src/main.cpp
  #define OBCOMMON OB_IMPORT
#else
  #define OBCOMMON OB_EXPORT
#endif


/* Used to export symbols for DLL / shared library builds */
#if defined(USING_OBDLL) // e.g. in src/main.cpp
  #define OBCONV OB_IMPORT
#else
  #define OBCONV OB_EXPORT
#endif


/* Used to export symbols for DLL / shared library builds */
#if defined(USING_OBDLL) // e.g. in src/main.cpp
  #define OBERROR OB_IMPORT
#else
  #define OBERROR OB_EXPORT
#endif


/* Used to export symbols for DLL / shared library builds */
#if defined(USING_OBDLL) // e.g. in src/main.cpp
  #define OBFPRT OB_IMPORT
#else
  #define OBFPRT OB_EXPORT
#endif


/* Define to the address where bug reports for this package should be sent. */

/* Define to the full name of this package. */

/* Define to the full name and version of this package. */

/* Define to the one symbol short name of this package. */

/* Define to the version of this package. */

/* set if scandir needs a const */
#define SCANDIR_CONST const

/* set if scandir needs a const */
#define SCANDIR_T (int (*)(const dirent *))


#if !HAVE_SNPRINTF
extern "C" int snprintf( char *, size_t, const char *, /* args */ ...);
#endif


/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1

/* Using BOOST for shared_pointer */
/* #undef USE_BOOST */

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
   significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
#  define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* #  undef WORDS_BIGENDIAN */
# endif
#endif

/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */

/* Define to `__inline__' or `__inline' if that's what the C compiler
   calls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
/* #undef inline */
#endif
LOCAL_PATH := $(call my-dir)/../src/
SRC_TOP_DIR := $(LOCAL_PATH)

include $(CLEAR_VARS)

LOCAL_MODULE := openbabel
LOCAL_CFLAGS := -DANDROID

LOCAL_SRC_FILES := atom.cpp alias.cpp base.cpp bitvec.cpp bond.cpp 
bondtyper.cpp canon.cpp builder.cpp chains.cpp chiral.cpp data.cpp 
descriptor.cpp fingerprint.cpp forcefield.cpp format.cpp generic.cpp 
griddata.cpp grid.cpp locale.cpp kekulize.cpp matrix.cpp mol.cpp molchrg.cpp 
obconversion.cpp oberror.cpp obiter.cpp obmolecformat.cpp obutil.cpp op.cpp 
ops.cpp parsmart.cpp patty.cpp phmodel.cpp plugin.cpp pointgroup.cpp rand.cpp 
residue.cpp ring.cpp rotor.cpp rotamer.cpp tokenst.cpp typer.cpp transform.cpp 
LOCAL_SRC_FILES += formats/smilesformat.cpp formats/getinchi.cpp 
formats/inchiformat.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include $(LOCAL_PATH)/../data

LOCAL_STATIC_LIBRARIES := math fingerprints inchi forcefields ops descriptors

include $(BUILD_SHARED_LIBRARY)

# math library
LOCAL_PATH := $(SRC_TOP_DIR)/math/

include $(CLEAR_VARS)

LOCAL_MODULE := math

LOCAL_SRC_FILES := matrix3x3.cpp spacegroup.cpp transform3d.cpp vector3.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include


include $(BUILD_STATIC_LIBRARY)

# fingerprints library
LOCAL_PATH := $(SRC_TOP_DIR)/fingerprints/

include $(CLEAR_VARS)

LOCAL_MODULE := fingerprints

LOCAL_SRC_FILES := finger2.cpp finger3.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include

include $(BUILD_STATIC_LIBRARY)

# inchi library
LOCAL_PATH := $(SRC_TOP_DIR)/formats/inchi102/

include $(CLEAR_VARS)

LOCAL_MODULE := inchi

LOCAL_SRC_FILES :=  ichi_bns.c ichi_io.c ichican2.c ichicano.c ichicans.c 
ichiisot.c ichilnct.c ichimak2.c ichimake.c ichimap1.c ichimap2.c ichimap4.c 
ichinorm.c ichiparm.c ichiprt1.c ichiprt2.c ichiprt3.c ichiqueu.c ichiread.c 
ichiring.c ichirvr1.c ichirvr2.c ichirvr3.c ichirvr4.c ichirvr5.c ichirvr6.c 
ichirvr7.c ichisort.c ichister.c ichitaut.c ikey_base26.c ikey_dll.c 
inchi_dll.c inchi_dll_a.c inchi_dll_a2.c inchi_dll_main.c runichi.c sha2.c 
strutil.c util.c
#LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../include/inchi102/


include $(BUILD_STATIC_LIBRARY)

# forcefields library
LOCAL_PATH := $(SRC_TOP_DIR)/forcefields/

include $(CLEAR_VARS)

LOCAL_MODULE := forcefields

LOCAL_SRC_FILES := forcefieldghemical.cpp forcefieldmmff94.cpp forcefielduff.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include

include $(BUILD_STATIC_LIBRARY)

# ops library
LOCAL_PATH := $(SRC_TOP_DIR)/ops/

include $(CLEAR_VARS)

LOCAL_MODULE := ops

LOCAL_SRC_FILES := addpolarh.cpp fillUC.cpp gen3d.cpp loader.cpp optransform.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include

include $(BUILD_STATIC_LIBRARY)

#descriptors library
LOCAL_PATH := $(SRC_TOP_DIR)/descriptors/

include $(CLEAR_VARS)

LOCAL_MODULE := descriptors

LOCAL_SRC_FILES := cmpdfilter.cpp filters.cpp groupcontrib.cpp 
smartsdescriptors.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include


include $(BUILD_STATIC_LIBRARY)

APP_MODULES := openbabel
APP_PROJECT_PATH := /home/igor/workspace/osra
APP_OPTIM := release
#APP_ABI := armeabi armeabi-v7a
APP_BUILD_SCRIPT := /home/igor/tmp/openbabel-2.2.3/jni/Android.mk
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to