How do you compile a C ++ console program to run as an android process?

I wrote a chess engine in C ++, which I want to compile to run in the Chess for Android application.

Here is an excerpt from a message from the author of the application, which very roughly describes how to start a third-party chess engine on your application:

Finally, developers can do all the development in C / C ++ and generate stand-alone native code using the appropriate compiler compilation (for example, CodeSourcery for ARM or the tool chain supplied with NDK). This third approach is used by Chess for Android to import engines that do not ship with the application.

Chess engine is a simple program. The application starts, the user sends it to the teams, the program thinks, and spits out a line with detailed information about the best move.

I do not need an application with graphics or anything else. this is ONLY the process that is passed through stdin / stdout (via channels really). The Chess for Android application takes care of talking to the process, I just need to figure out how to get my engine in the world as a process that can be launched by the Chess for Android application.

+4
source share
2 answers

You can create a traditional console program for Android in two ways.

  • Using the ndk-build system.

: Application.mk:

APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
APP_STL := stlport_static
NDK_TOOLCHAIN_VERSION := 4.8

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := <executable_name>
LOCAL_LDLIBS := -llog -lm # whatever libs you need
LOCAL_CFLAGS := -O3 -UNDEBUG # so on
LOCAL_C_INCLUDES := <list of a non-standard header directories>
LOCAL_SRC_FILES := <sources>
include $(BUILD_EXECUTABLE) # build executable instead of library

ABI, , STL . simfile , . . detais :

$ ndk-build NDK_PROJECT_PATH=path/to/intermediate/results/dir NDK_LIBS_OUT=path/to/output/dir APP_BUILD_SCRIPT=path/to/Android.mk NDK_APPLICATION_MK=path/to/Application.mk

, ndk-build . - V=1 .

  1. .

, , -. , , :

$NDK/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-21 --install-dir=/tmp/my-android-toolchain

:

$ export PATH=/tmp/my-android-toolchain/bin:$PATH
$ export CC=arm-linux-androideabi-gcc
$ export CXX=arm-linux-androideabi-g++

.

+3

, : UCI XBoard Engines Android

Android- x86 ( Google TV) , 32- x86 Linux. .

, Chess for Android , Linux. , Android Linux API- Linux. Android API Linux.

, 32- x86 Linux, Android- - x86, Linux-, , , .

Android, , x86, , ARM. -, , ARM Linux ( ). - , , ARM, x86, .

() Windows, , - Android NDK. ( , NDK , Android, Linux)

NDK gcc. .exe. , PATH NDK, gcc. , engine engine.cc, ARM

gcc -o MyUCIEngine engine.cc

, . , - NDK.

0

All Articles