building with C++11 for Latest Android NDK

A forum to store posts deemed exceptionally wise and useful
Post Reply
digijohnny
Posts: 63
Joined: Sat Sep 12, 2009 6:08 pm
Contact:

building with C++11 for Latest Android NDK

Post by digijohnny »

I'm in the process of (TRYING) to acclimate to the Android Studio.
which no longer support gnustl , only c++11.
this is what id did (im still using ndk-build, not cmake)


add or edit these changes to android mk files
---- application.mk
APP_STL:=c++_shared

--- android.mk
LOCAL_CXXFLAGS:=-std=c++11 -U __STRICT_ANSI__




-----add following to in irrlicht\source\os.h
#include <string.h>
#include <unistd.h>
#include <cmath>
#include <random>
#include <sstream>
#include <string>
#include <array>

---REMEMBER--- in you app code
refer to irrlicht array template as
core::array to avoid ambiguity errors/warnings


#################################################################
compile errors before the os.h fix pasted here in case anyone is searching for this:

jni/../../os.cpp: In static member function 'static irr::u32 irr::os::Timer::getRealTime()':
jni/../../os.cpp:186:3: error: 'timeval' was not declared in this scope
timeval tv;
^
jni/../../os.cpp:186:11: error: expected ';' before 'tv'
timeval tv;
^
jni/../../os.cpp:187:17: error: 'tv' was not declared in this scope
gettimeofday(&tv, 0);
^
jni/../../os.cpp:187:22: error: 'gettimeofday' was not declared in this scope
gettimeofday(&tv, 0);
^
jni/../../os.cpp: In static member function 'static irr::ITimer::RealTimeDate irr::os::Timer::getRealTimeAndDate()':
jni/../../os.cpp:310:16: error: 'time' was not declared in this scope
time(&rawtime);
^
jni/../../os.cpp:313:32: error: 'localtime' was not declared in this scope
timeinfo = localtime(&rawtime);
^
jni/../../os.cpp:322:27: error: invalid use of incomplete type 'struct tm'
date.Hour=(u32)timeinfo->tm_hour;
^
In file included from /home/hp/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../../android/support/include/stdio.h:44:0,
from ../../../include/IrrCompileConfig.h:18,
from jni/../../os.h:16,
from jni/../../os.cpp:5:
/home/hp/android-ndk-r10e/sources/cxx-stl/llvm-libc++/../../android/support/include/wchar.h:189:8: error: forward declaration of 'struct tm'
struct tm;

#######################################################################
Last edited by digijohnny on Sun Jan 27, 2019 7:54 am, edited 1 time in total.
CuteAlien
Admin
Posts: 9643
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: building with C++11 for Latest Android NDK

Post by CuteAlien »

You shouldn't really have to add <string> and <array> and <sstream> inside Irrlicht. Not sure about others right now. But those should only be needed in your own application as Irrlicht doesn't use any STL containers or streaming.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
digijohnny
Posts: 63
Joined: Sat Sep 12, 2009 6:08 pm
Contact:

Re: building with C++11 for Latest Android NDK

Post by digijohnny »

you are correct sir...
i omitted string,array, and sstream. build ok.
i just cut and pasted those headers from a current c++_shared NDK sample app, it built so i just went with that.
thank you so much for your input,
you comment on my other C++11 and android post motivated my to fix my src.
now i can start implementing google VR and VR_audio properly
Post Reply