Building Newton with the Android NDK

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Building Newton with the Android NDK

Postby Slick » Wed Mar 25, 2020 6:43 am

I have been able to do this in the past but it was never smooth and easy. I just decided to get back into it so I thought I'd share some of the issues I have.

The first errors are:
Code: Select all
[armeabi-v7a] Compile++ arm  : newtondynamics <= dg.cpp
In file included from S:/And2020Newton/Test/jni/dg.cpp:22:
In file included from S:/And2020Newton/Test/jni/dgStdafx.h:25:
S:/And2020Newton/Test/jni/dgTypes.h:550:4: error: "dgInterlockedExchange implementation required"
                #error "dgInterlockedExchange implementation required"
                 ^
S:/And2020Newton/Test/jni/dgTypes.h:588:4: error: "dgInterlockedTest implementation required"
                #error "dgInterlockedTest implementation required"
                 ^
2 errors generated.


Ideally I'd like a clean solution to the problems. Should I be using a specific define for building Newton on Android?
Slick
 
Posts: 272
Joined: Sat Feb 07, 2004 7:24 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby JernejL » Wed Mar 25, 2020 8:24 am

Which cmake parameters are you using?

Code: Select all
option("NEWTON_ARM32" "Cross compile to 32 bit Armv7-A" OFF)
option("NEWTON_ARM64" "Cross compile to 64 bit Armv8-A" OFF)


There are also switches for this to automaticly detect if you are compiling on an arm platform (example raspberry pi):

Code: Select all
# enable 32 / 64 defines so that x86-only stuff is properly disabled

if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
   set(NEWTON_ARM32 ON)
   # no vector class for arm32
   add_definitions(-DDG_SCALAR_VECTOR_CLASS)
endif()

if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
   set(NEWTON_ARM64 ON)
   # no vector class for arm64
   add_definitions(-DDG_SCALAR_VECTOR_CLASS)
endif()
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Building Newton with the Android NDK

Postby Slick » Wed Mar 25, 2020 8:28 am

Thanks for the response. I will look at it now since I'm working on it. I am not using CMake at all (I do when doing Windows coding). I am using the NDK-BUILD directly.
Slick
 
Posts: 272
Joined: Sat Feb 07, 2004 7:24 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby JernejL » Wed Mar 25, 2020 8:45 am

I checked cmake files and saw that some of my cmake patches were overwritten, I will try to get them integrated again.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Building Newton with the Android NDK

Postby Slick » Wed Mar 25, 2020 9:10 am

Ok thanks.

My current build problem is now:
Code: Select all
[armeabi-v7a] Compile++ arm  : newtondynamics <= dgAABBPolygonSoup.cpp
In file included from S:/And2020Newton/Test/jni/dgAABBPolygonSoup.cpp:26:
In file included from S:/And2020Newton/Test/jni/dgMatrix.h:28:
In file included from S:/And2020Newton/Test/jni/dgVector.h:33:
S:/And2020Newton/Test/jni/dgVectorScalar.h:414:10: error: invalid use of incomplete type 'dgBigVector'
                return dgBigVector (m_w, m_x, m_y, m_z);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
S:/And2020Newton/Test/jni/dgTypes.h:297:7: note: forward declaration of 'dgBigVector'
class dgBigVector;
      ^
1 error generated.


I think this might be from missing defines that I am not using or badly nested define checking in the Newton headers for an Android build.

Ideas?
Slick
 
Posts: 272
Joined: Sat Feb 07, 2004 7:24 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Slick » Wed Mar 25, 2020 9:20 am

Ok i fixed it by defining -D_NEWTON_USE_DOUBLE in my Android build defines. That does however leave the question as to how you would get Android to build using single precision.
Slick
 
Posts: 272
Joined: Sat Feb 07, 2004 7:24 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Julio Jerez » Wed Mar 25, 2020 11:03 am

yes it is abpout time we have to pay some attention.
the vector class for arm has to be completed. the neon classes has to be implemented.
what do I have do to get the Android build? is this done using visual studio?
can't tell about setting the process?

I hear some of the new arms are quite powerful, four way hyperthreaded per core, and even with tensor vector processors.
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Julio Jerez » Wed Mar 25, 2020 11:08 am

JernejL wrote:I checked cmake files and saw that some of my cmake patches were overwritten, I will try to get them integrated again.


JernejL, that was probably me aft merging some patches.
can you tell me hwo to get those in again can you?
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Slick » Wed Mar 25, 2020 11:14 am

In the past I had used Visual Studio but now I wanted to try and make it more straightforward (at least for me anyway). So my approach is just to use the Android NDK and create the Android.mk and Application.mk files then simply run ndk-build to build the Android libraries.

I did get it to build using the steps I mentioned above but have quite a way to go just to get it into an actual app to test if there any crashes/issues etc.

I had to do a fair amount of searching to try and understand which defines to use. Defines that seemed to have helped me overcome build errors are:
-D_NEWTON_USE_DOUBLE (although note my question above about the fact I can't get it to build at all without this. So how to do single?)
-D_POSIX_VER
Slick
 
Posts: 272
Joined: Sat Feb 07, 2004 7:24 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Julio Jerez » Wed Mar 25, 2020 12:08 pm

It is Linux?

On the define this is where cmake comes handy, it set the defines correctly for any platform or configuration.
At least that the idea.
Of course it will not work now because I broke the patch that jernell ill made
I will try to correct that.
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Slick » Wed Mar 25, 2020 12:10 pm

No I'm developing on Windows for Android (starting to again).

https://developer.android.com/ndk/downloads
Slick
 
Posts: 272
Joined: Sat Feb 07, 2004 7:24 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby JernejL » Thu Mar 26, 2020 2:19 am

Julio Jerez wrote:
JernejL wrote:I checked cmake files and saw that some of my cmake patches were overwritten, I will try to get them integrated again.


JernejL, that was probably me aft merging some patches.
can you tell me hwo to get those in again can you?


I'll try to make another patch but probably not be able to work on this before weekend, the patch i made actually succesfully compiled newton on raspberrypi for raspberrypi :)

execomrt had most of arm neon simd stuff for newton figured out here:
viewtopic.php?f=9&t=9304

His patches are in file here - "ARM PATCH 2.zip":
viewtopic.php?f=9&t=9304&hilit=neon#p63015
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1530
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Building Newton with the Android NDK

Postby Julio Jerez » Thu Mar 26, 2020 8:28 am

ah,
I see he did provided that patch,
I was wondering what happened, I separated the classes so that there he can made the update.
but the I never so teh patch, but is was in the form of a file. that's probably why I missed.
all the patches that has been applied were provided as GitHub merge.

I downloaded now and I will merge manually I doubt that afte so many changes, this will merge automatically so I will no even try.

I guess the first step is adding this merge
doing it now.
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Julio Jerez » Thu Mar 26, 2020 10:12 am

ok I added this file, is no working yet I made these defines

Code: Select all
// uncomment this for Scalar floating point
// alternatively the end application can use a command line option to enable this define
//#define DG_SCALAR_VECTOR_CLASS

// uncomment this for Scalar floating point
// alternatively the end application can use a command line option to enable this define
//#define __ANDROID__


they are in depended, but if both are defined them
DG_SCALAR_VECTOR_CLASS will take precedence.
if __ANDROID__ is defined the code will include dgVectorArmNeon.h
but there will be ton of errors.

I will try to bring it up to date with dgVectorSimd.h by going function by function
but now what we need if a way to do cross compilation to implement and test it.

when you fix the CMake, I will start fixing it.
meant time I see how to see the android sdk.

In visual studio I see that in CMake there are option for visual studio Arm configuration, I never try
so I do not know what that do.

anyway please tell me if that is how a project is set up for arm cross compilation.
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Building Newton with the Android NDK

Postby Julio Jerez » Thu Mar 26, 2020 11:44 am

FYI, in cmake I selected visual studio ARM configuration and is does indeed create an ARM solution
but does not compile, I get these errors everywhere

Code: Select all
10>  NewtonClass.cpp
11>cl : Command line warning D9002: ignoring unknown option '/arch:AVX'
11>  dgNewtonPluginStdafx.cpp
12>cl : Command line warning D9002: ignoring unknown option '/arch:AVX2'
12>  dgNewtonPluginStdafx.cpp
7>  vulkan.c
10>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\emmintrin.h(24): fatal error C1189: #error:  This header is specific to X86 and X64 targets
11>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\emmintrin.h(24): fatal error C1189: #error:  This header is specific to X86 and X64 targets
12>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\emmintrin.h(24): fatal error C1189: #error:  This header is specific to X86 and X64 targets
13>------ Build started: Project: dCustomJoints, Configuration: Debug ARM ------


The demonstrate that soem SDK need to be installed.
the teh CMake script need to be update so that it see appropriate options.
Julio Jerez
Moderator
Moderator
 
Posts: 11147
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 6 guests