C4droid is a simple C/C++ compiler for Android which has full support of ANSI C and some support of ISO C99. With C4DROID you can now write your own C/C++ code and run them right on your Android mobile. C4DROID comes with Makefile assistance and uses TCC compiler (with optional GCC compiler). C4DROID Also Supports SDL/NativeActivity/Qt apps for GUI, to use it you need to install additional plugins listed at the end of this post.
Compiling C++ projects:
- Make sure you have Enough internal memory.
- Install GCC plugin (C4droid will ask you to install it).
- Select G++ compiler in C4droid preferences.
- Use iostream, not iostream.h
- Add “using namespace std;” to your program (before int main)
Compiling Makefile projects:
- Open any file in the same folder with Makefile and long-click “Compile” to configure current directory (C4droid will create .c4droid configuration file when you’ll press Ok).
- After configuring folder, you can press compile button and C4droid will build your project.
- Don’t forget to enter executable name and select compilation mode (and press ok also, else changes will be discarded)
Compiling SDL/NativeActivity/Qt apps:
- To compile SDL/NativeActivity/Qt apps, you need GCC/G++ compiler selected (TCC is not supported).
- So First Install “GCC plugin for C4droid” from Google playstore.
- Now install “SDL plugin for C4droid“. Once you have installed both the plugins, you can now compile SDL/NativeActivity/Qt apps
- Make sure while compiling, GCC/G++ compiler selected is selected as TCC is not supported.
- SDL is detected with #include “SDL.h”, NativeActivity is detected with #include “android_native_app_glue.h”, Qt is detected with #include “QtGui”.
[ * ] If you have any “Illegal instruction” error, using internal compiler (TCC), Use GCC plugin instead, GCC supports softfloat (by default).