Pure C ++ program compiled for Android

I want to compile this program for Android and see how it works on my phone:

#include "Hello World.h" using namespace codewerks; //============================================= // Main Loop //============================================= int main(int argc, char* argv[]) { Print(std::string("Hello World!")); } 

Where to begin? Can I compile this with GCC? NDK seems to be focused on Java. Thanks.

+7
android android-ndk
source share
2 answers

This is now possible with the latest NDK. To do this, you need an emulator or phone running Android 2.3, but the NativeActivity documentation provides an example.

Unfortunately, this is somewhat more complicated than the simple hello world example, and main is android_main. You still need to worry about the life cycle of your application, as in Java, and the only real way to draw on the screen is to use OpenGL ES. It seems to be designed for writing Android games.

+3
source share

Build as an executable file. (BUILD_EXECUTABLE)
Copy the executable file to the SD card. (adb push)
Go to the android shell. (adb shell)
Change the resolution of the executable file. (chmod 777)
Run the executable file. (./out)
You will see the printed result on the console. (Happy?)

+1
source share

All Articles