glsl-optimizer icon indicating copy to clipboard operation
glsl-optimizer copied to clipboard

Building for android

Open robclouth opened this issue 8 years ago • 7 comments

Hello, I've struggled for 2 days now trying to build this for Android. I've managed to build the static libs, but linking them to the project is a bloody nightmare. Undefined variables all over the place. Does anyone have any source code I can browse to find the solution?

Thanks

robclouth avatar May 24 '16 11:05 robclouth

It seems that the std library in the ndk doesn't include some key functions like rand that the library uses. Has anyone managed to get this running on Android? I might end up having to use the emscriptened js version soon...

robclouth avatar May 24 '16 12:05 robclouth

Here's the config I used (with NDK 10e).

It's been a while but I vaguely recall modifying/deleting some of the source files as well.

In the end, it did run on Android, yes.

aliasaila avatar May 24 '16 14:05 aliasaila

Thanks a billion, you're a life saver.

On Tue, May 24, 2016 at 4:47 PM, aliasaila [email protected] wrote:

Here's the config https://gist.github.com/aliasaila/b5b041d3add88d4a4747c230f30e4eb4 I used (with NDK 10e).

It's been a while but I vaguely recall modifying/deleting some of the source files as well.

In the end, it did run on Android, yes.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/aras-p/glsl-optimizer/issues/127#issuecomment-221294921

robclouth avatar May 24 '16 15:05 robclouth

Ah ok, so you're actually building it in the Android.mk. I've been building it as a static lib with cmake then just wrapping it in the Android.mk.

robclouth avatar May 24 '16 15:05 robclouth

Ok got it! I wasted all that time trying to build it as a library first then wrap it, when I could have just built it directly with the Android.mk. Thanks!

robclouth avatar May 25 '16 08:05 robclouth

One thing for future android builders: this version of glsl-optimizer crashes when using the release build. You have to use this fork, which has some bug fixes that aren't in this repo.

robclouth avatar May 25 '16 09:05 robclouth

I think cmake was updated to work directly with the android NDK. So now you just do:

cmake . -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK="$NDK" -DCMAKE_ANDROID_ARCH_ABI=$ARCH -DCMAKE_SYSTEM_VERSION=21
make glsl_optimizer

Also, I had a similar issue with rand and what not. The issue I had was that the code I was linking against was compiling against platform-19 and glsl-optimizer was compiled for platform-21, which ins't compatible with 19. So I changed my codebase to compile against platform-21 and everything was fine.

kkirby avatar Apr 27 '17 16:04 kkirby