How to use Asio (standalone from Boost) in Android NDK?

蓝咒 提交于 2020-01-01 03:46:07

问题


Asio (without Boost) is supposed to be usable with just the headers only right?

By default, Asio is a header-only library. (http://think-async.com)

I understand that internally Asio still depends on Boost.

This is my setup.

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE        := gatelib
LOCAL_SRC_FILES     := gatelib.cpp
LOCAL_C_INCLUDES    += /cygdrive/l/asio-1.5.3/include
LOCAL_C_INCLUDES    += /cygdrive/l/boost/boost_1_49_0

include $(BUILD_SHARED_LIBRARY)

Application.mk

APP_STL := stlport_static
APP_CFLAGS += -DBOOST_DATE_TIME_NO_LIB -DBOOST_REGEX_NO_LIB

gatelib.cpp

#include <jni.h>
#include <asio.hpp>

#ifdef __cplusplus
extern "C" 
{
#endif
    // rest of code ...

#ifdef __cplusplus
}
#endif

Build script

@echo on

@set BASHPATH="L:\cygwin\bin\bash"
@set PROJECTDIR="/cygdrive/l/AsioAndroid/AsioDemo"
@set NDKDIR="/cygdrive/l/android-ndk-r8c/ndk-build"

%BASHPATH% --login -c "cd %PROJECTDIR% && %NDKDIR%

@pause:

Output

http://pastebin.com/XiJjvNmp

So basically, what I am trying to achieve is, get Asio working on Android (via NDK). Yes, just Asio itself, not the Asio included with Boost. The problems are presented in the output. I have no clue at all..

PS. There's no Asio tag, so I guess Boost-Asio tag will have to do for now.


回答1:


Here's what I did.

Application.mk

APP_STL := gnustl_static
APP_CFLAGS += -DBOOST_DATE_TIME_NO_LIB -DBOOST_REGEX_NO_LIB
APP_CPPFLAGS += -fexceptions

The clues and hints were all over Stack Overflow. Once pieced together, it worked!



来源:https://stackoverflow.com/questions/14135636/how-to-use-asio-standalone-from-boost-in-android-ndk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!