Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, June 15, 2022

Quitting Android development and almost stopping publishing to PlayStore.

From 2012 i started Android development and no single year has passed i felt comfortable with APIs or its user interface. I was making  innovative or rare hard to find apps like below.

- NGGallery (quit): which allowed slideshow of gallery images which speak their own information previously recorded by whoever clicked the pic.

- Binaural Sound Recorder (quit): Records stereo or binaural using 2 devices.

- BVH viewer (quit): bvh animated model viewer + BVH modifier (was WIP).

- Freeform Optics (quit): Makes complex lens and test how rays travel.

- Sacred Sound Visualizer (quit): Make cool flower like art from voice. Can also be used for various purposes.

- Image Size Reducer (nearly quit, just keeping updated to new Androids):  Select a region of image and just tell the KB size for it and app will take it out for you in fraction of time. Or reduce the size of whole image to desired size without loosing noticeable image quality. Does not work for already low quality images.

- Various apps like Sound Effect makers using wave painting, Voice to instrument sound generation etc. I have built both these apps and are sleeping in my disk not uploaded anywhere. I am now keeping only very simple apps and the ones which are very useful. I don't even care for updating them or investing more time to them. Some of them are SoundFont-MIDI-Player which offers low latency playback and piano for SF2 samples, Image Size Reducer & image converter.



Back to the topic. Android has massive issues for developers and i have removed all tech details posted here previously. I am sharing only the most critical ones which non tech end users can understand.


Reason #1:

PlayStore itself has become the reason to not publish on playstore. If you publish an app and your cannot find that app by searching the exact name of it what do your think it means?

PlayStore just sells the top 3 ranks! Imagine a sports competition where top 3 are paid winners. Below is an example where 50% of screen from top is just ads.




I searched games and the result shows top 3 with Ad text. Most users don't know they are ads. They think they are top ranking apps. Why so shy clearly highlighting the apps as ads? Using a little "Ad" which most cannot see or notice.


Every fall in rank almost reduces the download by ~30-50%. Some of my apps come to top 3 ranks since 2016. Daily downloads were minimum 1500+. Now after 3 ads the actual rank become 5+ and download fell to 300-450. Similar times loss in earnings. Post covid life of many people has changed. Now it has become impossible to have any interest in working anymore. Google will kill many developers and ultimately itself.


Google is obviously feeling the heat of falling economy and earnings but that means you just keep increasing ads? There might be other ways to experiment.


These things will only become worse by time. Whether its YouTube or something else. Everyone will witness the fall of internet world. Crazy, nonsensical things rising and huge compromise in ethics. The compitition where money wins doesn't promote hard work but economic unethical practitioners. But ultimately Its the people themselves who are responsible for this.


Reason #2:

Google terminated my YouTube account for something i was not responsible. Google updated their policy and said an app on playstore which shows a demo video which comes from youtube account MUST not have ads enabled in that video. What i did was i unpublished 10+ of my apps due to lack of maintenance and time etc issues. Google bots are oversmart. They scan even the unpublished apps and found a YouTube video link with monetization enabled. They terminated the YouTube account. I just used that account to make few videos about app demos and it had nothing which violates youtube policies. YouTube deleted the account in spamming violation.


Google Play Store applied policy violation on dead/unpublished apps. This is beyond understandable...


This motivated me so much i deleted 2nd account of YouTube myself. Now i use YouTube without account and its more fun than before.


Technical reasons:

Android development is hell in itself. I will describe it using analogy. Suppose you are learning painting on a painting app. Everytime you learn a feature and UI layout it's removed next year. Most new things become obsolete and suddenly some features return after some time. Your spend 10yrs learning the app and its UI but learned nothing about painting itself.


The file management SAF (document API) in Android is most crappiest thing i have seen in years of development. Just trying to check if some files exists can takes seconds which even 90s era computer will not. In name of security and generics the core has been compromised. If you don't want to allow an app to read other app's data then just use an encryption filter. Every app has its own encryption. Use intents to allow decrypted reading. I am thinking what makes Android more secure than Linux? Even after so much security user data is still being theft. Because the data itself has got no security. Only Android infrastructure has become secure the user data remains in same fate.


Android has definitely become much better and the changes were critical in need and also had great intention. But if it makes experience of both end user and developers bad the result is bad. 


I loved Android where i could listen to chiptunes, make awesome experimental apps, do innovation, playing with sensors etc.


Android has become IPhone. A well maintained jail with cool hardware that cannot be used for emulation, experimental apps etc like it was before. I cannot even enjoy using terminal shell.

 

Time has come for the innovative developers to say Android is dead or its not something to work for. Pure Linux must come to phone and it should not do what Android has done.


Thursday, July 29, 2021

Enhanced version of BeepFX 1.12 with export WAV and raw formats.

 The original version BeepFX 1.11 which is

"Beeper sound effects cross editor for ZX Spectrum 48K. Generates sound effects using small set of parameters, also has sample support. Source code included."

available at http://shiru.untergrund.net/software.shtml.

 

Original version is limited to ZX Spectrum users only however audio effects produced using just 1bit sound can be used in modern games also. The problem is it doesn't saves audio in wav etc format. For the same i edited the source and added Export RAW & WAV formats in batch. Editing source was not easy because i couldn't install Borland Studio 2006 on both Windows and Linux. So had to install VirtualBox with windowsXP and worked inside it. The source along with the BeepFX 1.12 binary is available below link -

https://drive.google.com/file/d/1b4A5NSbx5Nye2BuPHsM_lCIxEKkgbc7K/view?usp=sharing

 

There is also online version of similar software capable of producing nice audio effects.

Link - https://zx.remysharp.com/audio

 

Saturday, April 1, 2017

HTML5 canvas in a blogger.com page

I have been doing html5 for basic canvas graphics tests before building native code. With HTML5 we can build highly customized contents on a webpage. Example we can build a slideshow or some texts which cannot be copied. We can even build small apps on one blogpost. Below is a very simple example of adding html5 canvas on a blogger.com post.


Start with a new post on blogger.com and go to html edit mode. Its next to compose button. In html add the code mentioned below in post. The script which handles canvas resides in the canvas tag for easier management. After putting the code get back to compose mode and preview the page. The preview page will show the output as seen in this page.


Once happy publish it!. However there are limitations to this. Blogger.com posts don't give access to top level tag on html. As per the layout and template it offers editing in div tag in body. If we don't need exclusive access to screen and other similar things canvas inside blogger can do many multimedia work.


Copy the below script and add to your post in HTML edit mode.

Script:

<canvas height="200" id="canvas1" width="200">
Your browser does not supports canvas.

<script>
var canvas1 = document.getElementById("canvas1");
var context1 = canvas1.getContext("2d");
context1.fillRect(0, 0, 200, 200);
function loop() {
    context1.fillStyle = 'hsl(' + 360 * Math.random() + ', 50%, 50%)';
    context1.fillText("HTML5 Text!", 50, 50);
    // call loop again after 1000/5 milliseconds
    setTimeout( loop, 1000/6 );
}
loop();
</script>
</canvas>


Output of above script:
Your browser does not supports canvas.

Tuesday, March 14, 2017

Non GPL libsndfile alternative to read wav files. tinysndfile with Apache License, Version 2.0

A lot of people avoid using GPL in non-free software due to its imposed restrictions. I decided to use libsndfile which is GPL. But many people claim different restrictions as per GPL and i decided to avoid using this library because there were so many conflicting statements that i ended up with no conclusion. I still fear if someone claims for my GPL based projects on PlayStore to provide full source code!. I am not even maintaining many of them. If i am using GPL to process a wav file and i provide enough methods to enhance that GPL part of code why i am forced to provide rest of code?. This way one can even claim whole operating system to become GPL!!!. That's why Android Project decided to go with Apache License.


With above case in mind many developers built software with simpler licenses not imposing loads of terms and conditions. tinysndfile is such alternative to libsndfile. This library is available here https://android.googlesource.com/platform/system/media/+/master/audio_utils. tinysndfile is Android only and requires some editing to make it work on *NIX. I have done that work and stripped audio_utils to extract out tinysndfile. Using this library wav file can be read to get PCM data. It supports common wav files. Whether its a commercial project or a free software use it without fear of any legal issues.



Why tinysndfile?


Look at libsndfile page http://www.mega-nerd.com/libsndfile/ . Below text is read from the same -


"Licensing

libsndfile is released under the terms of the GNU Lesser General Public License, of which there are two versions; version 2.1 and version 3. To maximise the compatibility of libsndfile, the user may choose to use libsndfile under either of the above two licenses. You can also read a simple explanation of the ideas behind the GPL and the LGPL here.

You can use libsndfile with Free Software, Open Source, proprietary, shareware or other closed source applications as long as libsndfile is used as a dynamically loaded library and you abide by a small number of other conditions (read the LGPL for more info). With applications released under the GNU GPL you can also use libsndfile statically linked to your application.

I would like to see libsndfile used as widely as possible but I would prefer it if you released software that uses libsndfile as Free Software or Open Source. However, if you put in a great deal of effort building a significant application which simply uses libsndfile for file I/O, then I have no problem with you releasing that as closed source and charging as much money as you want for it as long as you abide by the license."



Small number of other terms are so much that i avoided using it. Such a great software i decide not to use :(. Example of such other terms are -


https://www.gnu.org/licenses/why-not-lgpl.en.html


https://source.android.com/source/licenses.html#why-apache-software-license



Don't forget to read the GPL section -

http://www.cgal.org/license.html




Download links:

You can download my non-Android version of tinysndfile from here https://github.com/bindeshkumarsingh/android-native-libs/blob/master/tinysndfile-src-nix.7z

Compiling libjpeg-turbo 1.5.1 on Android

I tried to build Turbo JPEG libary using cmake and then encountered "Platform not supported by this build system.  Use autotools instead.". This is because the author has hard-coded cmake script for windows platform only. I tried to modify cmake and build turbo-jpeg but before that i built it using configure script.


I created below script to build turbo-jpeg. The configure script automatically enabled NEON support after checking ARM environment. Anyone can use this script by changing variables like NDK, ARCH, PLATFORM etc.

This script will not work without some editing. There may be other ways to compile successfully but i was getting SIZE_MAX undefined error so i simply added #include in jmemmgr.c and completed building the binaries. File BUILDING.md has instructions to build Android version.


AndroidBuild.sh :
#!/bin/sh
# http://www.ourinnovativemind.in
# http://www.gamesgreh.in

export CONFIGURATION_OPTIONS="--disable-shared --enable-static"


# use custom build environment

# installation directory
export PREFIX=`pwd`/prefix

# Path of NDK. For simplicity make symlinks in home directories
export NDK=/home/bindesh/bin/ndk/

# processor specific libraries and includes.
# Suffix for arch-???. arch-arm  arch-arm64  arch-mips  arch-mips64  arch-x86  arch-x86_64
export ARCH=arm

# compiler for processor
export CROSS_COMPILE=arm-linux-androideabi

# Android platform version
export PLATFORM=android-9

# GCC compiler version
export GCC_VERSION=4.9


# Getting toolchain directory inside NDK from variables set above
# Hardcoded for linux running on x86 cpu 64-Bit
export ANDROID_PREFIX=${NDK}/toolchains/$CROSS_COMPILE-$GCC_VERSION/prebuilt/linux-x86_64

# SYSROOT. usr dir i.e. usr/include, usr/lib
export SYSROOT=${NDK}/platforms/$PLATFORM/arch-$ARCH
export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}

# Some compiler and binutils. More might be needed depending on source. 
export CPP=${CROSS_PATH}-cpp
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-as
export NM=${CROSS_PATH}-nm
export CC=${CROSS_PATH}-gcc
export CXX=${CROSS_PATH}-g++
export LD=${CROSS_PATH}-ld
export RANLIB=${CROSS_PATH}-ranlib


# package configuration file save location
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig

# Flags for compiler
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"

./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" $CONFIGURATION_OPTIONS
make
make install



Below is the log file dumped after running this script. The resulting binaries can be downloaded from https://github.com/bindeshkumarsingh/android-native-libs/blob/master/libjpeg-turbo-1.5.1_Android.7z.

I haven't used this build for making a libjpeg client app. I expect it will work.


log :
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking how to run the C preprocessor... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
checking for arm-linux-androideabi-gcc... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... (cached) yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... (cached) none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... (cached) yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... (cached) gcc3
checking for arm-linux-androideabi-ar... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking the archiver (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar) interface... ar
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
checking if the linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm
checking the name lister (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-androideabi format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld option to reload object files... -r
checking for arm-linux-androideabi-objdump... no
checking for objdump... objdump
configure: WARNING: using cross tools not prefixed with host triplet
checking how to recognize dependent libraries... pass_all
checking for arm-linux-androideabi-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-androideabi-ar... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking for archiver @FILE support... @
checking for arm-linux-androideabi-strip... strip
checking for arm-linux-androideabi-ranlib... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
checking command to parse /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm output from /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok
checking for sysroot... /home/bindesh/bin/ndk//platforms/android-9/arch-arm
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-linux-androideabi-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to produce PIC... -fPIC -DPIC
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc PIC flag -fPIC -DPIC works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc static flag -static works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... (cached) yes
checking whether the /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether ln -s works... yes
checking for arm-linux-androideabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking size of size_t... 4
checking whether compiler supports pointers to undefined structures... yes
checking whether __SUNPRO_C is declared... no
checking for ANSI C header files... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for string.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether char is unsigned... yes
checking for inline... inline
checking for size_t... yes
checking for unsigned char... yes
checking for unsigned short... yes
checking if right shift is signed... Assuming that right shift is signed on target machine.
checking for memset... yes
checking for memcpy... yes
checking libjpeg API version... 6.2
checking whether to include in-memory source/destination managers... yes
checking libjpeg shared library version... 62.2.0
checking whether the linker supports version scripts... yes (GNU style)
checking whether to use version script when building libjpeg-turbo... yes
checking for inline... inline __attribute__((always_inline))
checking whether to include arithmetic encoding support... yes
checking whether to include arithmetic decoding support... yes
checking whether to use 12-bit samples... no
checking whether to build TurboJPEG C wrapper... yes
checking whether to build TurboJPEG Java wrapper... no
checking if we have SIMD optimisations for cpu type... yes (arm)
checking if the assembler is GNU-compatible and can be used... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating pkgscripts/libjpeg-turbo.spec.tmpl
config.status: creating pkgscripts/makecygwinpkg.tmpl
config.status: creating pkgscripts/makedpkg.tmpl
config.status: creating pkgscripts/makemacpkg.tmpl
config.status: creating pkgscripts/uninstall.tmpl
config.status: creating pkgscripts/libjpeg.pc
config.status: creating pkgscripts/libturbojpeg.pc
config.status: creating tjbenchtest
config.status: creating libjpeg.map
config.status: creating Makefile
config.status: creating simd/Makefile
config.status: creating java/Makefile
config.status: creating md5/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: creating jconfig.h
config.status: jconfig.h is unchanged
config.status: creating jconfigint.h
config.status: jconfigint.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Making all in java
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making all in simd
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  all-am
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making all in md5
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
  CC       jmemmgr.lo
jmemmgr.c: In function 'realize_virt_arrays':
jmemmgr.c:659:11: error: 'SIZE_MAX' undeclared (first use in this function)
       if (SIZE_MAX - maximum_space < new_space)
           ^
jmemmgr.c:659:11: note: each undeclared identifier is reported only once for each function it appears in
Makefile:1170: recipe for target 'jmemmgr.lo' failed
make[2]: *** [jmemmgr.lo] Error 1
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Makefile:2031: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Makefile:790: recipe for target 'all' failed
make: *** [all] Error 2
Making install in java
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making install in simd
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  install-am
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making install in md5
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
  CC       jmemmgr.lo
jmemmgr.c: In function 'realize_virt_arrays':
jmemmgr.c:659:11: error: 'SIZE_MAX' undeclared (first use in this function)
       if (SIZE_MAX - maximum_space < new_space)
           ^
jmemmgr.c:659:11: note: each undeclared identifier is reported only once for each function it appears in
Makefile:1170: recipe for target 'jmemmgr.lo' failed
make[1]: *** [jmemmgr.lo] Error 1
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Makefile:2031: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1
bindesh@bindesh-Satellite-C650D:/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1$ sh AndroidBuild.sh 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-androideabi-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking for arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking how to run the C preprocessor... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
checking for arm-linux-androideabi-gcc... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... (cached) yes
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ISO C89... (cached) none needed
checking whether /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc understands -c and -o together... (cached) yes
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... (cached) gcc3
checking for arm-linux-androideabi-ar... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking the archiver (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar) interface... ar
checking dependency style of /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
checking if the linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm
checking the name lister (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-androideabi format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld option to reload object files... -r
checking for arm-linux-androideabi-objdump... no
checking for objdump... objdump
configure: WARNING: using cross tools not prefixed with host triplet
checking how to recognize dependent libraries... pass_all
checking for arm-linux-androideabi-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-androideabi-ar... (cached) /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
checking for archiver @FILE support... @
checking for arm-linux-androideabi-strip... strip
checking for arm-linux-androideabi-ranlib... /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
checking command to parse /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm output from /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok
checking for sysroot... /home/bindesh/bin/ndk//platforms/android-9/arch-arm
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-linux-androideabi-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no
checking for /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to produce PIC... -fPIC -DPIC
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc PIC flag -fPIC -DPIC works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc static flag -static works... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... yes
checking if /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... (cached) yes
checking whether the /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc linker (/home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes
checking dynamic linker characteristics... Android linker
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether ln -s works... yes
checking for arm-linux-androideabi-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking size of size_t... 4
checking whether compiler supports pointers to undefined structures... yes
checking whether __SUNPRO_C is declared... no
checking for ANSI C header files... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for string.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether char is unsigned... yes
checking for inline... inline
checking for size_t... yes
checking for unsigned char... yes
checking for unsigned short... yes
checking if right shift is signed... Assuming that right shift is signed on target machine.
checking for memset... yes
checking for memcpy... yes
checking libjpeg API version... 6.2
checking whether to include in-memory source/destination managers... yes
checking libjpeg shared library version... 62.2.0
checking whether the linker supports version scripts... yes (GNU style)
checking whether to use version script when building libjpeg-turbo... yes
checking for inline... inline __attribute__((always_inline))
checking whether to include arithmetic encoding support... yes
checking whether to include arithmetic decoding support... yes
checking whether to use 12-bit samples... no
checking whether to build TurboJPEG C wrapper... yes
checking whether to build TurboJPEG Java wrapper... no
checking if we have SIMD optimisations for cpu type... yes (arm)
checking if the assembler is GNU-compatible and can be used... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating pkgscripts/libjpeg-turbo.spec.tmpl
config.status: creating pkgscripts/makecygwinpkg.tmpl
config.status: creating pkgscripts/makedpkg.tmpl
config.status: creating pkgscripts/makemacpkg.tmpl
config.status: creating pkgscripts/uninstall.tmpl
config.status: creating pkgscripts/libjpeg.pc
config.status: creating pkgscripts/libturbojpeg.pc
config.status: creating tjbenchtest
config.status: creating libjpeg.map
config.status: creating Makefile
config.status: creating simd/Makefile
config.status: creating java/Makefile
config.status: creating md5/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: creating jconfig.h
config.status: jconfig.h is unchanged
config.status: creating jconfigint.h
config.status: jconfigint.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Making all in java
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making all in simd
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  all-am
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making all in md5
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
  CC       jmemmgr.lo
  CC       jmemnobs.lo
  CC       jaricom.lo
  CC       jcarith.lo
  CC       jdarith.lo
  CCLD     libjpeg.la
  CC       libturbojpeg_la-jcapimin.lo
  CC       libturbojpeg_la-jcapistd.lo
  CC       libturbojpeg_la-jccoefct.lo
  CC       libturbojpeg_la-jccolor.lo
  CC       libturbojpeg_la-jcdctmgr.lo
  CC       libturbojpeg_la-jchuff.lo
  CC       libturbojpeg_la-jcinit.lo
  CC       libturbojpeg_la-jcmainct.lo
  CC       libturbojpeg_la-jcmarker.lo
  CC       libturbojpeg_la-jcmaster.lo
  CC       libturbojpeg_la-jcomapi.lo
  CC       libturbojpeg_la-jcparam.lo
  CC       libturbojpeg_la-jcphuff.lo
  CC       libturbojpeg_la-jcprepct.lo
  CC       libturbojpeg_la-jcsample.lo
  CC       libturbojpeg_la-jctrans.lo
  CC       libturbojpeg_la-jdapimin.lo
  CC       libturbojpeg_la-jdapistd.lo
  CC       libturbojpeg_la-jdatadst.lo
  CC       libturbojpeg_la-jdatasrc.lo
  CC       libturbojpeg_la-jdcoefct.lo
  CC       libturbojpeg_la-jdcolor.lo
  CC       libturbojpeg_la-jddctmgr.lo
  CC       libturbojpeg_la-jdhuff.lo
  CC       libturbojpeg_la-jdinput.lo
  CC       libturbojpeg_la-jdmainct.lo
  CC       libturbojpeg_la-jdmarker.lo
  CC       libturbojpeg_la-jdmaster.lo
  CC       libturbojpeg_la-jdmerge.lo
  CC       libturbojpeg_la-jdphuff.lo
  CC       libturbojpeg_la-jdpostct.lo
  CC       libturbojpeg_la-jdsample.lo
  CC       libturbojpeg_la-jdtrans.lo
  CC       libturbojpeg_la-jerror.lo
  CC       libturbojpeg_la-jfdctflt.lo
  CC       libturbojpeg_la-jfdctfst.lo
  CC       libturbojpeg_la-jfdctint.lo
  CC       libturbojpeg_la-jidctflt.lo
  CC       libturbojpeg_la-jidctfst.lo
  CC       libturbojpeg_la-jidctint.lo
  CC       libturbojpeg_la-jidctred.lo
  CC       libturbojpeg_la-jquant1.lo
  CC       libturbojpeg_la-jquant2.lo
  CC       libturbojpeg_la-jutils.lo
  CC       libturbojpeg_la-jmemmgr.lo
  CC       libturbojpeg_la-jmemnobs.lo
  CC       libturbojpeg_la-jaricom.lo
  CC       libturbojpeg_la-jcarith.lo
  CC       libturbojpeg_la-jdarith.lo
  CC       libturbojpeg_la-turbojpeg.lo
  CC       libturbojpeg_la-transupp.lo
  CC       libturbojpeg_la-jdatadst-tj.lo
  CC       libturbojpeg_la-jdatasrc-tj.lo
  CCLD     libturbojpeg.la
  CC       cjpeg-cdjpeg.o
  CC       cjpeg-cjpeg.o
  CC       cjpeg-rdgif.o
  CC       cjpeg-rdppm.o
  CC       cjpeg-rdswitch.o
  CC       cjpeg-rdbmp.o
  CC       cjpeg-rdtarga.o
  CCLD     cjpeg
  CC       djpeg-cdjpeg.o
  CC       djpeg-djpeg.o
  CC       djpeg-rdcolmap.o
  CC       djpeg-rdswitch.o
  CC       djpeg-wrgif.o
  CC       djpeg-wrppm.o
  CC       djpeg-wrbmp.o
  CC       djpeg-wrtarga.o
  CCLD     djpeg
  CC       jpegtran.o
  CC       rdswitch.o
  CC       cdjpeg.o
  CC       transupp.o
  CCLD     jpegtran
  CC       rdjpgcom.o
  CCLD     rdjpgcom
  CC       wrjpgcom.o
  CCLD     wrjpgcom
  CC       tjbench-tjbench.o
  CC       tjbench-bmp.o
  CC       tjbench-tjutil.o
  CC       tjbench-rdbmp.o
  CC       tjbench-rdppm.o
  CC       tjbench-wrbmp.o
  CC       tjbench-wrppm.o
  CCLD     tjbench
  CC       jcstest.o
  CCLD     jcstest
  CC       tjunittest.o
  CC       tjutil.o
  CCLD     tjunittest
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
Making install in java
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/java'
Making install in simd
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make  install-am
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/simd'
Making install in md5
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/md5'
make[1]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
make[2]: Entering directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libjpeg.la libturbojpeg.la '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib'
libtool: install: /usr/bin/install -c .libs/libjpeg.lai /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.la
libtool: install: /usr/bin/install -c .libs/libturbojpeg.lai /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.la
libtool: install: /usr/bin/install -c .libs/libjpeg.a /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.a
libtool: install: chmod 644 /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.a
libtool: install: /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libjpeg.a
libtool: install: /usr/bin/install -c .libs/libturbojpeg.a /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.a
libtool: install: chmod 644 /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.a
libtool: install: /home/bindesh/bin/ndk//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/libturbojpeg.a
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c cjpeg djpeg jpegtran rdjpgcom wrjpgcom tjbench '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin'
libtool: install: /usr/bin/install -c cjpeg /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/cjpeg
libtool: install: /usr/bin/install -c djpeg /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/djpeg
libtool: install: /usr/bin/install -c jpegtran /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/jpegtran
libtool: install: /usr/bin/install -c rdjpgcom /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/rdjpgcom
libtool: install: /usr/bin/install -c wrjpgcom /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/wrjpgcom
libtool: install: /usr/bin/install -c tjbench /media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/bin/tjbench
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /usr/bin/install -c -m 644 README.ijg README.md libjpeg.txt structure.txt usage.txt wizard.txt LICENSE.md '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /usr/bin/install -c -m 644 example.c '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/doc/libjpeg-turbo'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /usr/bin/install -c -m 644 jerror.h jmorecfg.h jpeglib.h turbojpeg.h '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/man/man1'
 /usr/bin/install -c -m 644 cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1 '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/share/man/man1'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /usr/bin/install -c -m 644 jconfig.h '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/include'
 /bin/mkdir -p '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/pkgconfig'
 /usr/bin/install -c -m 644 pkgscripts/libjpeg.pc pkgscripts/libturbojpeg.pc '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1/prefix/lib/pkgconfig'
make[2]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'
make[1]: Leaving directory '/media/bindesh/WORK/Software/libraries/libjpeg-turbo-1.5.1'





Saturday, February 25, 2017

NEW: Building libpng 1.6.28 using Android NDK r13 CMake based build system

I recently updated to NDK revision 13 and also found ndk samples are now cmake + ninja based. Today 3-4 hours were consumed while trying to compile libpng but finally done it after editing CMakeLists.txt of libpng.

I tried to build libpng using Androud Studio's Gradle plugin from IDE but that was more problematic as it too required CMakeLists.txt editing and kept throwing bad link to libpng.so error. I decided to use shell which is my 1st and last choice to work in most cases. Before putting the scripts/code lets setup our work directory and data and also look at how cmake based build system compiles libpng.


Before starting ensure below tools are installed and working correctly on your system.

  • Android NDK revision 12+ is installed. If you have Android SDK installed but NDK is at some other location then you can move NDK inside SDK and rename it to ndk-bundle Or create a sym-link "ndk-bundle" in SDK pointing to actual NDK. After this NDK will start showing in the Android Studio 2.2+ SDK manager.
  • Install cmake from SDK manager. It will get extracted in Android SDK directory.
  • A good command shell. I use Ubuntu-Studio Linux with bash shell(s). Windows users can use cmd.exe or bash shell through UnixUtils.


Build process:

  1. Dowload libpng 1.6.28 from here http://ftp.osuosl.org/pub/blfs/conglomeration/libpng/libpng-1.6.28.tar.xz and extract to some location with shorter path without spaces. e.g. /home/username/projects/libpng in Linux or c:\work\libpng in windows. This is for convenience and avoid space related issues while compiling.
  2. Copy full path of android.toolchain.cmake present in NDK. Example /media/bindesh/WORK/SDK_IDE/android-ndk-r13b/build/cmake/android.toolchain.cmake. There is same named file present in ANDROID_SDK/cmake/ like this /media/bindesh/WORK/SDK_IDE/android-sdk-linux-windows/cmake/3.6.3155560/android.toolchain.cmake but we must use toolchain file present in NDK. If toolchain present in sdk/cmake is used incompatibility issues like "Invalid Android NDK revision (should be 12" can occur.
  3. Open libpng/CMakeLists.txt file in text editor and add include("/home/bindesh/bin/ndk/build/cmake/android.toolchain.cmake") line after project(libpng C). Change the NDK path to yours.

Copy below bash script to create a file build.sh in libpng folder. Change the cmake, ninja, toolchain, sdk, ndk paths in script and run to build libpng. Replace the toolchain path copied through above steps. I have not tested this on Windows but using UnixUtils's sh.exe it should work.


build script:
#!/bin/sh

# run this script after changing the paths of ndk, sdk, cmake, ninja etc to build libpng or other cmake based library.
# Don't forget to add below line in main CMakeLists.txt after project() line of code.
# include("PATH_TO_NDK/build/cmake/android.toolchain.cmake")

clear
reset

# clean previous files
rm CMakeCache.txt


# Change these paths and run this script to build libpng
ANDROID_NDK_PATH=/home/bindesh/bin/ndk
ANDROID_SDK_PATH=/home/bindesh/bin/android-sdk
ANDROID_NDK=${ANDROID_NDK_PATH}

ANDROID_CMAKE_PATH=${ANDROID_SDK_PATH}/cmake/3.6.3155560/bin
ANDROID_CMAKE_TOOLCHAIN=${ANDROID_NDK_PATH}/build/cmake/android.toolchain.cmake

# Don't use toolchain from cmake
#ANDROID_CMAKE_TOOLCHAIN=/media/bindesh/WORK/SDK_IDE/android-sdk-linux-windows/cmake/3.6.3155560/android.toolchain.cmake


ANDROID_API=9
ANDROID_ARCH=arm
ANDROID_ABI=armeabi-v7a
ANDROID_PLATFORM=android-${ANDROID_API}
ANDROID_ARCH=arch-${ANDROID_ARCH}

${ANDROID_CMAKE_PATH}/cmake -DCMAKE_TOOLCHAIN_FILE=${ANDROID_CMAKE_TOOLCHAIN} -DANDROID_ABI=${ANDROID_ABI} -DANDROID_TOOLCHAIN=gcc -DANDROID_NATIVE_API_LEVEL=${ANDROID_API} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DCMAKE_MAKE_PROGRAM=${ANDROID_CMAKE_PATH}/ninja -G"Android Gradle - Ninja" 
#-DCMAKE_BUILD_TYPE=Release

#${ANDROID_CMAKE_PATH}/cmake -DCMAKE_TOOLCHAIN_FILE=${ANDROID_CMAKE_TOOLCHAIN} -DCMAKE_MAKE_PROGRAM=${ANDROID_CMAKE_PATH}/ninja -G"Android Gradle - Ninja" -DANDROID_NDK=${ANDROID_NDK}
${ANDROID_CMAKE_PATH}/ninja
#make 
 

mv ./libpng16.a ./libpng16-${ANDROID_ABI}.a


 


Below is the CMakeOutput.log to check details of build environment.

Preview:
The target system is: Android - 9 - armv7-a
The host system is: Linux - 4.8.0-22-lowlatency - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc 
Build flags: -g;-DANDROID;-ffunction-sections;-funwind-tables;-fstack-protector-strong;-no-canonical-prefixes;-march=armv7-a;-mfloat-abi=softfp;-mfpu=vfpv3-d16;-mthumb;-Wa,--noexecstack;-Wformat;-Werror=format-security;-g;-DANDROID;-ffunction-sections;-funwind-tables;-fstack-protector-strong;-no-canonical-prefixes;-march=armv7-a;-mfloat-abi=softfp;-mfpu=vfpv3-d16;-mthumb;-Wa,--noexecstack;-Wformat;-Werror=format-security;
Id flags: -c

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"

The C compiler identification is GNU, found in "/media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/3.6.0-rc2/CompilerIdC/CMakeCCompilerId.o"

Determining if the C compiler works passed with the following output:
Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp

Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_76f0a"
[1/2] Building C object CMakeFiles/cmTC_76f0a.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_76f0a


Detecting C compiler ABI info compiled with the following output:
Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp

Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_7ad81"
[1/2] Building C object CMakeFiles/cmTC_7ad81.dir/CMakeCCompilerABI.c.o
[2/2] Linking C executable cmTC_7ad81
Using built-in specs.
COLLECT_GCC=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
COLLECT_LTO_WRAPPER=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper
Target: arm-linux-androideabi
Configured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot --with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default
Thread model: posix
gcc version 4.9.x 20150123 (prerelease) (GCC) 
COMPILER_PATH=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/
LIBRARY_PATH=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/:/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-D' 'ANDROID' '-fstack-protector-strong' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb' '-Wformat=1' '-Werror=format-security' '-g' '-D' 'ANDROID' '-ffunction-sections' '-funwind-tables' '-fstack-protector-strong' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb' '-Wformat=1' '-Werror=format-security' '-v' '-o' 'cmTC_7ad81' '-mtls-dialect=gnu'
 /home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/collect2 -plugin /home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/liblto_plugin.so -plugin-opt=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper -plugin-opt=-fresolution=/tmp/ccNet1nu.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-ldl -plugin-opt=-pass-through=-lgcc --sysroot=/home/bindesh/bin/ndk/platforms/android-9/arch-arm --eh-frame-hdr -dynamic-linker /system/bin/linker -X -m armelf_linux_eabi -z noexecstack -z relro -z now -o cmTC_7ad81 /home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_dynamic.o -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib -L/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib --build-id --warn-shared-textrel --fatal-warnings --fix-cortex-a8 --no-undefined -z noexecstack -z relro -z now --gc-sections -z nocopyreloc CMakeFiles/cmTC_7ad81.dir/CMakeCCompilerABI.c.o -lgcc -lc -ldl -lgcc /home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/crtend_android.o


Parsed C implicit link information from above output:
  link line regex: [^( *|.*[/\])(arm-linux-androideabi-ld|([^/\]+-)?ld|collect2)[^/\]*( |$)]
  ignore line: [Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp]
  ignore line: []
  ignore line: [Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_7ad81"]
  ignore line: [[1/2] Building C object CMakeFiles/cmTC_7ad81.dir/CMakeCCompilerABI.c.o]
  ignore line: [[2/2] Linking C executable cmTC_7ad81]
  ignore line: [Using built-in specs.]
  ignore line: [COLLECT_GCC=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc]
  ignore line: [COLLECT_LTO_WRAPPER=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper]
  ignore line: [Target: arm-linux-androideabi]
  ignore line: [Configured with: /usr/local/google/buildbot/src/android/gcc/toolchain/build/../gcc/gcc-4.9/configure --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --target=arm-linux-androideabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/buildbot/tmp/build/toolchain/temp-install --with-mpfr=/buildbot/tmp/build/toolchain/temp-install --with-mpc=/buildbot/tmp/build/toolchain/temp-install --with-cloog=/buildbot/tmp/build/toolchain/temp-install --with-isl=/buildbot/tmp/build/toolchain/temp-install --with-ppl=/buildbot/tmp/build/toolchain/temp-install --disable-ppl-version-check --disable-cloog-version-check --disable-isl-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --enable-bionic-libs --enable-libatomic-ifuncs=no --enable-initfini-array --disable-nls --prefix=/tmp/59719db9ae19ff43aef46bbcb79596b6 --with-sysroot=/tmp/59719db9ae19ff43aef46bbcb79596b6/sysroot --with-binutils-version=2.25 --with-mpfr-version=3.1.1 --with-mpc-version=1.0.1 --with-gmp-version=5.0.5 --with-gcc-version=4.9 --with-gdb-version=none --with-gxx-include-dir=/tmp/59719db9ae19ff43aef46bbcb79596b6/include/c++/4.9.x --with-bugurl=http://source.android.com/source/report-bugs.html --enable-languages=c,c++ --disable-bootstrap --enable-plugins --enable-libgomp --enable-gnu-indirect-function --disable-libsanitizer --enable-gold --enable-threads --enable-eh-frame-hdr-for-static --enable-graphite=yes --with-isl-version=0.11.1 --with-cloog-version=0.18.0 --with-arch=armv5te --program-transform-name='s&^&arm-linux-androideabi-&' --enable-gold=default]
  ignore line: [Thread model: posix]
  ignore line: [gcc version 4.9.x 20150123 (prerelease) (GCC) ]
  ignore line: [COMPILER_PATH=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/]
  ignore line: [LIBRARY_PATH=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/:/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/:/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/]
  ignore line: [COLLECT_GCC_OPTIONS='-g' '-D' 'ANDROID' '-fstack-protector-strong' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb' '-Wformat=1' '-Werror=format-security' '-g' '-D' 'ANDROID' '-ffunction-sections' '-funwind-tables' '-fstack-protector-strong' '-march=armv7-a' '-mfloat-abi=softfp' '-mfpu=vfpv3-d16' '-mthumb' '-Wformat=1' '-Werror=format-security' '-v' '-o' 'cmTC_7ad81' '-mtls-dialect=gnu']
  link line: [ /home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/collect2 -plugin /home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/liblto_plugin.so -plugin-opt=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper -plugin-opt=-fresolution=/tmp/ccNet1nu.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-ldl -plugin-opt=-pass-through=-lgcc --sysroot=/home/bindesh/bin/ndk/platforms/android-9/arch-arm --eh-frame-hdr -dynamic-linker /system/bin/linker -X -m armelf_linux_eabi -z noexecstack -z relro -z now -o cmTC_7ad81 /home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_dynamic.o -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc -L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib -L/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib --build-id --warn-shared-textrel --fatal-warnings --fix-cortex-a8 --no-undefined -z noexecstack -z relro -z now --gc-sections -z nocopyreloc CMakeFiles/cmTC_7ad81.dir/CMakeCCompilerABI.c.o -lgcc -lc -ldl -lgcc /home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/crtend_android.o]
    arg [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/collect2] ==> ignore
    arg [-plugin] ==> ignore
    arg [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/liblto_plugin.so] ==> ignore
    arg [-plugin-opt=/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../libexec/gcc/arm-linux-androideabi/4.9.x/lto-wrapper] ==> ignore
    arg [-plugin-opt=-fresolution=/tmp/ccNet1nu.res] ==> ignore
    arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
    arg [-plugin-opt=-pass-through=-lc] ==> ignore
    arg [-plugin-opt=-pass-through=-ldl] ==> ignore
    arg [-plugin-opt=-pass-through=-lgcc] ==> ignore
    arg [--sysroot=/home/bindesh/bin/ndk/platforms/android-9/arch-arm] ==> ignore
    arg [--eh-frame-hdr] ==> ignore
    arg [-dynamic-linker] ==> ignore
    arg [/system/bin/linker] ==> ignore
    arg [-X] ==> ignore
    arg [-m] ==> ignore
    arg [armelf_linux_eabi] ==> ignore
    arg [-znoexecstack] ==> ignore
    arg [-zrelro] ==> ignore
    arg [-znow] ==> ignore
    arg [-o] ==> ignore
    arg [cmTC_7ad81] ==> ignore
    arg [/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_dynamic.o] ==> ignore
    arg [-L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb] ==> dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb]
    arg [-L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb] ==> dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb]
    arg [-L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x] ==> dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x]
    arg [-L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc] ==> dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc]
    arg [-L/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib] ==> dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib]
    arg [-L/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib] ==> dir [/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib]
    arg [--build-id] ==> ignore
    arg [--warn-shared-textrel] ==> ignore
    arg [--fatal-warnings] ==> ignore
    arg [--fix-cortex-a8] ==> ignore
    arg [--no-undefined] ==> ignore
    arg [-znoexecstack] ==> ignore
    arg [-zrelro] ==> ignore
    arg [-znow] ==> ignore
    arg [--gc-sections] ==> ignore
    arg [-znocopyreloc] ==> ignore
    arg [CMakeFiles/cmTC_7ad81.dir/CMakeCCompilerABI.c.o] ==> ignore
    arg [-lgcc] ==> lib [gcc]
    arg [-lc] ==> lib [c]
    arg [-ldl] ==> lib [dl]
    arg [-lgcc] ==> lib [gcc]
    arg [/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib/crtend_android.o] ==> ignore
  remove lib [gcc]
  remove lib [gcc]
  collapse library dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb] ==> [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb]
  collapse library dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib/armv7-a/thumb] ==> [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/lib/armv7-a/thumb]
  collapse library dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x] ==> [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x]
  collapse library dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc] ==> [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc]
  collapse library dir [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/lib] ==> [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/lib]
  collapse library dir [/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib] ==> [/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib]
  implicit libs: [c;dl]
  implicit dirs: [/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a/thumb;/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/lib/armv7-a/thumb;/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x;/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc;/home/bindesh/bin/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/lib;/home/bindesh/bin/ndk/platforms/android-9/arch-arm/usr/lib]
  implicit fwks: []




Detecting C [-std=c11] compiler features compiled with the following output:
Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp

Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_5d10b"
[1/2] Building C object CMakeFiles/cmTC_5d10b.dir/feature_tests.c.o
[2/2] Linking C executable cmTC_5d10b


    Feature record: C_FEATURE:1c_function_prototypes
    Feature record: C_FEATURE:1c_restrict
    Feature record: C_FEATURE:1c_static_assert
    Feature record: C_FEATURE:1c_variadic_macros


Detecting C [-std=c99] compiler features compiled with the following output:
Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp

Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_bb98c"
[1/2] Building C object CMakeFiles/cmTC_bb98c.dir/feature_tests.c.o
[2/2] Linking C executable cmTC_bb98c


    Feature record: C_FEATURE:1c_function_prototypes
    Feature record: C_FEATURE:1c_restrict
    Feature record: C_FEATURE:0c_static_assert
    Feature record: C_FEATURE:1c_variadic_macros


Detecting C [-std=c90] compiler features compiled with the following output:
Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp

Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_f387f"
[1/2] Building C object CMakeFiles/cmTC_f387f.dir/feature_tests.c.o
[2/2] Linking C executable cmTC_f387f


    Feature record: C_FEATURE:1c_function_prototypes
    Feature record: C_FEATURE:0c_restrict
    Feature record: C_FEATURE:0c_static_assert
    Feature record: C_FEATURE:0c_variadic_macros
Performing C SOURCE FILE Test HAVE_LD_VERSION_SCRIPT succeeded with the following output:
Change Dir: /media/bindesh/WORK/00_write/libpng-1.6.28/CMakeFiles/CMakeTmp

Run Build Command:"/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/ninja" "cmTC_d0d1b"
[1/2] Building C object CMakeFiles/cmTC_d0d1b.dir/src.c.o
[2/2] Linking C executable cmTC_d0d1b

Source file was:
void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}



Head of CMakeLists.txt file for reference

# CMakeLists.txt

# Copyright (C) 2007,2009-2016 Glenn Randers-Pehrson
# Written by Christian Ehrlicher, 2007
# Revised by Roger Lowman, 2009-2010
# Revised by Clifford Yapp, 2011-2012
# Revised by Roger Leigh, 2016
# Revised by Andreas Franek, 2016

# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h

cmake_minimum_required(VERSION 2.8.3)
cmake_policy(VERSION 2.8.3)

# Set MacOSX @rpath usage globally.
if (POLICY CMP0020)
  cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
if (POLICY CMP0042)
  cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)
# Use new variable expansion policy.
if (POLICY CMP0053)
  cmake_policy(SET CMP0053 NEW)
endif(POLICY CMP0053)
if (POLICY CMP0054)
  cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)

set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")

project(libpng C)
enable_testing()

set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 28)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})


include("/home/bindesh/bin/ndk/build/cmake/android.toolchain.cmake")


# needed packages

#Allow users to specify location of Zlib, 
# Useful if zlib is being built alongside this as a sub-project
option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) 




This script will build libpng for specified ABI. Change the ABI to build x86, MIPS etc binaries. Sample output binary for above script can be downloaded from here:

 
https://github.com/bindeshkumarsingh/android-native-libs/blob/master/armeabi-v7a_libpng-1.6.28.7z

Wednesday, February 22, 2017

Android Studio NDK and CMake build system. Compiling hello-jni using cmake without Android Studio.

This post will be short and to the point. Android Studio and development tools have reached very stable and feature rich state in past few years after Android Studio was released. However it is still hard for many developers trying to use NDK 1st time. Now NDK has become more easier than before!. Thanks to CMake build system.


While building many c/c++ libraries like libpng, webp, fluidsynth, imagemagick, jpegoptim, vorbis, freetype etc i used Android.mk based build system. However while looking at new ndk samples i found CMake based source codes. Lets start learning basics of CMake build system by building hello-jni without using Android Studio.


Firstly ensure all SDK and NDK are installed before proceeding further. Use SDK manager to install platform, platform-tools, build-tools, tools (SDK tools), cmake, ndk and other required packages like Google support libraries. After all is done the directories in the installed location will contain these folders -

licenses
add-ons
lldb
patcher
sources
build-tools
platforms
tools
cmake/3.6.3155560
platform-tools
docs
samples
extras
... etc


In list above we can see cmake version. This means cmake is installed. Before cmake ndk-build command was used to build c/c++ codes present inside jni folder. That ndk-build script required some hard-coded paths like presence of jni folder, manifest file. Using Cmake its more convenient to build native binaries.


Download hello-jni from here. Extract the zip go to hello-jni/app/src/main/cpp/ and start a command shell bash etc in Linux and cmd.exe etc in Windows. Execute cmake from shell. Like this -


/home/bindesh/bin/android-sdk/cmake/3.6.3155560/bin/cmake -DCMAKE_TOOLCHAIN_FILE=/home/bindesh/bin/ndk/build/cmake/android.toolchain.cmake


This command tells cmake to use Android NDK's toolchain to build ARM/X86/MIPS binary. It dumps text like below -


-- Check for working C compiler: /home/bindesh/bin/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/bindesh/bin/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/bindesh/bin/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/bindesh/bin/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /media/bindesh/WORK/Software/Android/NDK/android-ndk-master/hello-jni/app/src/main/cpp



CMake's job is to identify development tools and configuration. The job of toolchain file it to supply the configuration. Open android.toolchain.cmake file in a text editor to see what it does. CMake creates a Makefile by default. After Makefile is created run make and this will show messages like -


[ 50%] Building C object CMakeFiles/hello-jni.dir/hello-jni.c.o
[100%] Linking C shared library libhello-jni.so
[100%] Built target hello-jni


libhello-jni.so file is created and ready to be used by Android Java project. Cmake can be used to easily change project configurations like adding libraries, custom header paths, external libraries etc.


You can read about cmake in Android NDK docs here https://developer.android.com/ndk/guides/cmake.html#build-command


To learn more how jni binary was built you can read contents of CMakeFiles folder created by cmake. In this folder more details can be found. For example hello-jni/app/src/main/cpp/CMakeFiles/hello-jni.dir/flags.make file contains the CFLAGS, -D, -I, -L flags we pass in a makefile or Android.mk. The good thing is we have to deal with CMakeLists.txt file ONLY. All thing is done from here. Refer to cmake help pages for more information. Use cmake --help to see what more it can do. This article focused on building hello-jni from command like without using Android Studio.



Important links -

https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android

https://developer.android.com/studio/projects/add-native-code.html#create-cmake-script

https://developer.android.com/ndk/guides/cmake.html#build-command

https://cmake.org/Wiki/CMake_Cross_Compiling


This article is very short so i will probably (if i didn't forgot!) write advanced ndk project compilation articles like compiling libpng, libjpeg etc using CMake.