Reputation: 741
I was looking for a way to build the Xerces-C++ library for Android that I need as a dependency of Delta3D game engine, but could not find any information on this. I would very much appreciate a professional advice.
Upvotes: 0
Views: 1284
Reputation: 1
If you want to build the Xerces library, follow these steps:
Android.mk for Xerces
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# List of all subdirectories in src/xercesc/
XERCES_SUBDIRS := $(shell find $(LOCAL_PATH)/src/xercesc/ -type d)
# Name of the library
LOCAL_MODULE := xerces1
# Check the target architecture
ifeq ($(TARGET_ARCH), armeabi-v7a)
LOCAL_CFLAGS += -march=armv7-a
endif
# Exclude specific files and include all .cpp files from the root and subdirectories
LOCAL_SRC_FILES := $(filter-out src/xercesc/util/Transcoders/MacOSUnicodeConverter/MacOSUnicodeConverter.cpp, $(wildcard $(LOCAL_PATH)/xerces/src/*.cpp))
# Include paths for Xerces-C++ headers
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/include/xercesc/util \
$(LOCAL_PATH)/include/xercesc/util/MsgLoaders/InMemory \
$(LOCAL_PATH)/include/xercesc/dom \
$(LOCAL_PATH)/include/xercesc/dom/impl \
$(LOCAL_PATH)/include/xercesc/validators/schema/identity \
$(LOCAL_PATH)/include/xercesc/util/Transcoders/IconvGNU \
$(LOCAL_PATH)/include/xercesc/sax
# Compilation flags
LOCAL_CFLAGS := -Os -DHAVE_CONFIG_H -frtti -fexceptions
# Specify the C++ file extension
LOCAL_CPP_EXTENSION := .cpp
# Add the source files from the root of the src directory
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/src/*.cpp)
# Add the source files from all subdirectories of src/xercesc
LOCAL_SRC_FILES += $(foreach subdir, $(XERCES_SUBDIRS), $(wildcard $(subdir)/*.cpp))
# Build as a shared library
include $(BUILD_SHARED_LIBRARY)
Android.mk for jni Folder
# Define the local path for the current directory
LOCAL_PATH := $(call my-dir)
# Specify the STL to use
APP_STL := c++_shared
# Include the Xerces-C++ Android.mk file
include $(LOCAL_PATH)/xerces/Android.mk
# Clear any previous settings
include $(CLEAR_VARS)
# Define the module name for the Xerces library
LOCAL_MODULE := xerces
# Specify the source files to be compiled
# If you want to include specific files, adjust accordingly
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/xerces/src/*.cpp)
# Include directories for Xerces-C++ headers
LOCAL_C_INCLUDES := $(LOCAL_PATH)/xerces/include \
$(LOCAL_PATH)/xerces/include/xercesc/util \
$(LOCAL_PATH)/xerces/include/xercesc/dom \
$(LOCAL_PATH)/xerces/include/xercesc/validators/schema/identity \
$(LOCAL_PATH)/xerces/include/xercesc/sax
# Compiler flags
LOCAL_CFLAGS := -Os -frtti -fexceptions -DHAVE_CONFIG_H
# Build as a shared library
include $(BUILD_SHARED_LIBRARY)
Application.mk for jni Folder
# Set the project path
APP_PROJECT_PATH := $(call my-dir)/..
# Specify the application ABI (Architecture Binary Interface)
APP_ABI := armeabi-v7a # Set to armeabi-v7a for 32-bit ARM
# Specify the platform level (API level)
APP_PLATFORM := android-21 # Minimum API level for your application
# Specify the STL to use
APP_STL := c++_shared
# Additional compiler flags
APP_CFLAGS := -g -Os -frtti -fexceptions -DHAVE_CONFIG_H
# Enable PIE (Position Independent Executable)
APP_PIE := true
# Additional flags for linking
SDL_EXCLUDE_LIBGCC := -Wl,--exclude-libs,libgcc.a
SDL_EXCLUDE_LIBUNWIND := -Wl,--exclude-libs,libunwind.a
APP_LDFLAGS = $(if $(filter clang%, $(NDK_TOOLCHAIN_VERSION)), $(SDL_EXCLUDE_LIBGCC) $(if $(filter armeabi%, $(APP_ABI)), $(SDL_EXCLUDE_LIBUNWIND)))
# Disable debug mode by default
ifneq ($(NDK_DEBUG),1)
APP_CFLAGS += -Oz -DNDEBUG # Use optimized settings for release builds
endif
Build the Xerces Library
ndk-build
Upvotes: 0
Reputation: 13958
You can copy xercesc library with Android build scripts from here.
Just copy it into your jni folder and run ndk-build.
Upvotes: 3
Reputation: 906
Most Android development is done in Java. The Delta3D game engine is in C++, which means you'll need to start with the Android Native Development Kit (NDK). The FAQ claims that the library uses cross-platform dependencies, so, in theory you should be able to use it on Android. However, it is written for OpenGL, not OpenGL ES, which is the subset used in Android. This could cause an issue. The other concern would be memory footprint. There is a fair amount of work that will probably need to be done to get this to compile under Android. You might consider working with a library which has already been ported to Android (or written for it) rather than all the work that will be needed to port this, let alone writing your game. Unless, you already have a game written in this game engine, which I understand why you would want to just port the library over.
Upvotes: 2