android-spatialite icon indicating copy to clipboard operation
android-spatialite copied to clipboard

Figure out how to build Geos on NDK. (C++/STL support)

Open mrenouf opened this issue 13 years ago • 8 comments

Geos is not supported because the Android NDK apparently lacks the most basic of C++ library support (no STL!). Right now it fails with missing headers for most of the stuff in /usr/include/c++. So right now, I've removed it from the build (-DOMIT_GEOS=1).

mrenouf avatar Mar 14 '11 03:03 mrenouf

When I was poking around with it this past weekend I was able to get GEOS to compile by specifying some C++-specific stuff in the Android.mk file. Here's what my makefile looked like:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := libgeos
LOCAL_C_INCLUDES := \
        $(LOCAL_PATH)/include \
        $(LOCAL_PATH)/source/headers
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%)
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl
LOCAL_STL                 := gnustl_static
LOCAL_CPPFLAGS            += -fexceptions
LOCAL_CPPFLAGS            += -frtti

LOCAL_SRC_FILES := \
        source/inlines.cpp \
        source/operation/buffer/SubgraphDepthLocater.cpp \
        source/operation/buffer/RightmostEdgeFinder.cpp \
        source/operation/buffer/BufferSubgraph.cpp \
        source/operation/buffer/OffsetCurveSetBuilder.cpp \
        ....
        source/util/GeometricShapeFactory.cpp \
        source/util/math.cpp

include $(BUILD_SHARED_LIBRARY)

iandees avatar Mar 15 '11 19:03 iandees

Hi iandees, I'm new at all this, I'm trying to crosscompile geos to Android, I've two questions, is the make file read automatically when building or how do I use it? as well what are the ... for? I use this to compile:

#SET compile flags
CXX=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ \
CXXFLAGS="-nostdlib -I$NDK_PLATFORM/usr/include -I$NDK/sources/cxx-stl/gnu-libstdc++/include -I$NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -DHAVE_ISNAN" \
CC=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc \
CFLAGS="  -nostdlib -I$NDK_PLATFORM/usr/include -I$NDK/sources/cxx-stl/gnu-libstdc++/include -I$NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include" \
LDFLAGS="-L$NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L$NDK_PLATFORM/usr/lib --sysroot=$NDK_PLATFORM -Wl,-rpath-link=$NDK_PLATFORM/usr/lib -lc" \
./configure --prefix=$INSTALL_DIR --host=arm-linux-androideabi

#COMPILE LIB
make -j$CORES 2>&1 | tee make.out

Thanks a lot Marco

mbernasocchi avatar Jun 09 '11 08:06 mbernasocchi

The .... is me cutting out the listing of all the cpp files in the GEOS distribution.

iandees avatar Jun 09 '11 10:06 iandees

I immagined that. the other issue was the more important one ;)

mbernasocchi avatar Jun 09 '11 11:06 mbernasocchi

You don't run Make when building NDK projects. Read the readme for the project or the NDK docs.

Basically, you run ndk_build in the parent directory.

iandees avatar Jun 09 '11 11:06 iandees

Did we ever get this all to work reliably?

The project I initially wanted this for has come and gone, and I ended up building a simple K-d tree which can do what I needed quickly, finding nearest n-neighbors.

On Thu, Jun 9, 2011 at 7:29 AM, iandees [email protected] wrote:

You don't run Make when building NDK projects. Read the readme for the project or the NDK docs.

Basically, you run ndk_build in the parent directory.

Reply to this email directly or view it on GitHub: https://github.com/mrenouf/android-spatialite/issues/1#comment_1333582

mrenouf avatar Jun 09 '11 12:06 mrenouf

Yea, we're actually using it in a yet-to-be-released product. There are some big performance problems, but we haven't spent any time looking into what the problem is.

Depending on the timing we might end up switching to a K-D tree as well...

On Thu, Jun 9, 2011 at 7:57 AM, mrenouf < [email protected]>wrote:

Did we ever get this all to work reliably?

The project I initially wanted this for has come and gone, and I ended up building a simple K-d tree which can do what I needed quickly, finding nearest n-neighbors.

On Thu, Jun 9, 2011 at 7:29 AM, iandees [email protected] wrote:

You don't run Make when building NDK projects. Read the readme for the project or the NDK docs.

Basically, you run ndk_build in the parent directory.

Reply to this email directly or view it on GitHub: https://github.com/mrenouf/android-spatialite/issues/1#comment_1333582

Reply to this email directly or view it on GitHub: https://github.com/mrenouf/android-spatialite/issues/1#comment_1333963

iandees avatar Jun 09 '11 13:06 iandees

Hi, i compiled geos using the standalone toolchain of r5c with less issues than using mk files. Thanks for the hints anyway

mbernasocchi avatar Jul 05 '11 11:07 mbernasocchi