FB group

Join our facebook group

Symphony Custom ROM Developer

Tuesday 29 May 2018

Compile cpp code for android in windows environment .

So you want to compile c++ code for android to test it on your device ? Follow the procedure .

1=>Download android NDK  in windows.
2=>Go to your android sdk path/ndk-bundle/build/tools
3=> Now open run and type cmd to open a cmd window.

4=>Drag the make_standalone_toolchain.py from the folder you opened .

5=> now type --arch=arm (Most android runs on arm ) other options are 'arm', 'arm64', 'mips', 'mips64', 'x86', 'x86_64'.

6=> --api=17 (Enter your androdi version api level)

7=>--install-dir= "Dir where you want to install" (Don't enter a existing directory)

9=> SO the whole command looks like


10=>Now you will get the desired folder.

11=> Inside the folder (cpp-compiler in this case) look for bin .
12=> Now open a cmd window

13=> Drag arm-linux-androideabi-g++.exe into cmd then type space -o "compiled object location here" "source file location".




14=> Now you will find your object under gcc folder (in this case).


15=>Copy the object named main into your device .
16=>Copy that into data folder of your device (You need root permission)

17=>Give right permissions(I used xplore file manager).
18=> Now open terminal emulator and execute . :)









No comments:

Post a Comment