Need support for compiling on android

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

lostsky
Posts: 1
Joined: 20 Feb 2016, 05:23

Need support for compiling on android

Postby lostsky » 21 Feb 2016, 03:09

Hi, all
Is there a tutorial for compiling c++API v1.6 on android?
I found a post at http://www.smartfoxserver.com/forums/viewtopic.php?f=34&t=16247,
but it's about c++API v1.1.6 which only has .a file of boost v1.52.

The latest c++API requires boost v1.59 and openssl.
How to generate boost v1.59 static library and openssl .a file?

Thank you all.
User avatar
Lapo
Site Admin
Posts: 20276
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Need support for compiling on android

Postby Lapo » 22 Feb 2016, 15:16

Hi,
I've forwarded your question to our C++ expert, he will get back to you asap.

Stay tuned.
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 26 Feb 2016, 00:48

Hi,
I am trying to prepare a tutorial to build API for Android environment.
Currently I am taking a look at these url that seem contain interesting suggestions

For Boost library:
http://www.plungeinteractive.com/blog/2013/12/09/integrate-boost-in-ios-android/
https://github.com/MysticTreeGames/Boost-for-Android
http://stackoverflow.com/questions/17667978/using-boost-in-android-ndk-with-windows

For OpenSSL
https://wiki.openssl.org/index.php/Android

Please stay tuned, I will work on this direction to give you additional info asap
Thanks
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 05 Mar 2016, 15:52

Hi
I am still working to discover how build Boost and OpenSSL for Android platform.
After a lot of retries now my attention is focused on these url:

https://rubentorresbonet.wordpress.com/2014/08/22/cross-compiling-boost-1-56-for-android-arm-and-intel-on-windows-with-ndk-r9d-and-gcc-4-8/
http://munteanumarian.blogspot.it/2014/10/build-boost-for-android.html

that seem to provide interesting suggestions but based on a file system architecture that is a little different from that one
created by installation of Android Studio (https://developer.android.com/sdk/insta ... pkg=studio) and NDK r10e (https://developer.android.com/ndk/downloads/index.html)

I'll go on with my tests; at moment I have not found any guideline to successfully build Boost

Sorry for the delay to provide you a working solution
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 10 Mar 2016, 22:16

Hi,
I have found a path to build the Boost library for Android platform...it seems to work on my Windows Pc...
Let me to tell you.

I have installed in C:\Android\android-ndk-r10e the NDK r10e package downloaded from https://developer.android.com/ndk/downloads/index.html
Please note a trick! The downloaded zip file must be unzipped two times on the same target directory because the first time it does not create all files !

I have downloaded Boost libary rel 1.59 from official website (https://sourceforge.net/projects/boost/files/boost/1.59.0)

Inside the folder <Boost directory>\tools\build\src I have created a new text file, named user-config.jam, with this content

Code: Select all

 import os ; 
 androidNDKRoot = C:/Android/android-ndk-r10e ;
  using gcc : android : 
    $(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ : 
    <compileflags>--sysroot=$(androidNDKRoot)/platforms/android-9/arch-arm 
    <compileflags>-mthumb 
    <compileflags>-Os 
    <compileflags>-fno-strict-aliasing 
    <compileflags>-O2 
    <compileflags>-DNDEBUG 
    <compileflags>-g 
    <compileflags>-lstdc++ 
    <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/include 
    <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include 
    <compileflags>-D__GLIBC__   
    <compileflags>-D__arm__ 
    <archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar 
    <ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ranlib 
      ; 

I have opened a Visual Studio Developer Command Prompt on the <Boost directory> folder to execute the command
bootstrap

When bootstrap was completed, I have executed these commands

b2 -a toolset=gcc-android target-os=linux threading=multi link=static runtime-link=shared --with-system stage
b2 -a toolset=gcc-android target-os=linux threading=multi link=static runtime-link=shared --with-date_time stage
b2 -a toolset=gcc-android target-os=linux threading=multi link=static runtime-link=shared --with-chrono stage
b2 -a toolset=gcc-android target-os=linux threading=multi link=static runtime-link=shared --with-regex stage
b2 -a toolset=gcc-android target-os=linux threading=multi link=static runtime-link=shared --with-thread stage


and finally I have got the Boost library for Android

Let me know if it solves the problem
g1111111g
Posts: 5
Joined: 29 Dec 2010, 11:53
Contact:

Re: Need support for compiling on android

Postby g1111111g » 04 Jun 2016, 03:21

Hi Mbagnati,I got this error when i complie android in cocos2d,pls help me.
Attachments
aaa.png
(31.15 KiB) Not downloaded yet
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 23 Jun 2016, 08:49

Hi,
I suggest you to verify if is defined BOOST_THREAD_PROVIDES_FUTURE.
I think that you have not BOOST_THREAD_PROVIDES_FUTURE and this can be the cause of compiler error

Please take a look at this post
http://www.smartfoxserver.com/forums/viewtopic.php?t=18274
minh_129
Posts: 4
Joined: 17 Feb 2017, 08:45

Re: Need support for compiling on android

Postby minh_129 » 20 Feb 2017, 07:54

Hi MBagnati, i got this error when execute command: b2 -a toolset=gcc-android target-os=linux threading=multi link=static runtime-link=shared --with-thread stage. Pls help me.
Image
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 20 Feb 2017, 14:59

Hi,
The image you have attached to your post, makes me assume that you are building the Boost library for Linux from a Windows environment.
The builder of Boost thread is deducing that the building context is Windows, so it tries to use the Windows includes.
For this reason it looks for <process.h>, that is a Windows-only header.

I suggest you to try one of these ways:
  • try to force Boost build to use Unix thread adding

    threadapi=pthread

    This setting must be declared as parameter in b2 command
    For instance
    b2 -a toolset=gcc-android target-os=linux threadapi=pthread threading=multi link=static ...
  • Move to a Linux environment to build Boost for a Linux target

Let me know if it solves the problem
minh_129
Posts: 4
Joined: 17 Feb 2017, 08:45

Re: Need support for compiling on android

Postby minh_129 » 21 Feb 2017, 01:47

Thank you MBagnati :D. By the way, by the way, can you help me to build openssl for android in windows?
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 24 Feb 2017, 09:29

Hi,
I have created a Windows Virtual Machine with Android Studio, Android NDK and MSYS/MinGW
In this virtual machine I have installed OpenSSL 1.1.0e
I think that this is all it is necessary to build OpenSSL on a Window PC for Android platform, but unfortunately I have an error due to PERL version of MSYS
The installed PERL release is 5.8.8 while OpenSSL needs of rel. 5.10

Please stay tuned, I hope to overcome this problem
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: Need support for compiling on android

Postby MBagnati » 25 Feb 2017, 01:47

Hi,
I have not yet solved the issue, but I done some little steps along a way that sounds good, so I give you a little update.

OpenSSL website provides the download of two different library versions: rel. 1.1.0 and rel. 1.0.2k
To build library rel. 1.1.0 is required Perl rel. 5.10 (or above)
To build library rel. 1.0.2k is required Perl rel. 5.8.8
The Windows tools to build for Android platform contain, by default, Perl rel. 5.8.8 and I am not yet able to upgrade to rel. 5.10.
So for this reason, at the moment I have tried to build OpenSSL rel. 1.0.2k instead of rel. 1.1.0

To build OpenSSL library, I have done these steps on my PC:
  • downloaded file openssl-1.0.2k.tar.gz from Download section of https://www.openssl.org/
  • unzipped openssl-1.0.2k.tar.gz to get openssl-1.0.2k.tar
  • unzipped openssl-1.0.2k.tar to get openssl-1.0.2k source files
  • downloaded MinGW setup from https://sourceforge.net/projects/mingw/files/latest/download
  • installed MinGW (see attached Image01 and Image02)
  • installed mingw-developer-tool from MinGW Installation Manager
  • installed Android NDK (downloaded file android-ndk-r13b-windows-x86_64 from Android website)
  • copied NDK directory into \MinGW\msys\1.0
  • copied OpenSSL source files into \MinGW\msys\1.0\home\<USER>
  • executed (double click) msys batch file from Windows folder \MinGW\msys\1.0
  • from MinGW shell, executed the command
    Configure android
    to create the make file for Android platform (see attached Image03)
    When command execution is completed, you can see that Makefile file in folder \MinGW\msys\1.0\home\<USER>\openssl-1.0.2k has been updated
  • edit Makefile file to change

    Code: Select all

       CC= /Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc
       CFLAG= -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -mandroid -I$(ANDROID_DEV)/include -B$(ANDROID_DEV)/lib -O3-fomit-frame-pointer -Wall
       AR= /Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar $(ARFLAGS) r

    with

    Code: Select all

    CC= /ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc
    CFLAG= -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -mandroid -I$(ANDROID_DEV)/include -B$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall -I/ndk/platforms/android-24/arch-arm/usr/include
    AR= /ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ar $(ARFLAGS) r

  • from MinGW sheel, folder C:\MinGW\msys\1.0\home\<USER>\openssl-1.0.2k, executed the command
    makefile

The makefile command is able to compile OpenSSL source files with success, but fails the link phase
Attachments
Image03.png
(18.35 KiB) Not downloaded yet
Image02.png
(93.99 KiB) Not downloaded yet
Image01.png
(52.23 KiB) Not downloaded yet
minh_129
Posts: 4
Joined: 17 Feb 2017, 08:45

Re: Need support for compiling on android

Postby minh_129 » 28 Feb 2017, 02:39

Thanks MBagnati. I'm temporarily using SSL v1.0.2 prebuilt that i downloaded from github. But with your help, now I can make for my own.

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: No registered users and 0 guests