Need a Simple Linux C++ Ide (Android Ndk)

Need a simple Linux C++ IDE (Android NDK)

I configured Code::Blocks for Android NDK/JNI development, but there's a trick.
Codeblocks believes that it can know what compiler you use, and wants to stop you from using something it does not know. You have to trick it.

  1. Create an empty codeblocks project
  2. Add your source and header files (manually)
  3. Click the right mouse button on your project in the workspace (the left pane). You will see a menu: the two useful menu items
    (EDIT: First go to Properties and specify it's a custom Makefile, then to Build options)
  4. Go to "Properties" and tell CB it has a custom Makefile. Do not tell it anything close to the truth about the platform: it will tell you that you don't have the required compiler and will not even attempt to build something.
    custom makefile
  5. Finally, in the Build options, select the GNU GCC Compiler, go to the "Make commands", and write your custom commands. (Personally I created a Makefile that invokes ndk-build -- I prefer to keep scripts in the text files rather than in GUI dialogs. The item that you might want to change is -j 4)build options

And one final note: if your configuration does not work, you get no meaningful diagnostics.

PS Here's my Makefile:

all:
@echo '====all===='
pwd;~/android-ndk-r7/ndk-build -j 4
clean:
@echo '====clean===='
pwd;~/android-ndk-r7/ndk-build clean

.PHONY: clean
.PHONY: all

Need an IDE for Android NDK + SDK development

I'll recommend to use Android-Studio based on IntelliJ IDEA from jetBrains when there will be a v1 release, its UI is clear and effective and the debugger is less annoying than eclipse's one, however native development is a bit tricky unlike eclipse which provides the appropriated plugins when you write your module in C++ (if you do it in C, the compiler will take it as an error when you'll open your file in the IDE).
So I'll develop in native using eclipse until a native module exists for Android Studio.

How to compile C code using NDK for Android Device (ARM)?

You're right, I made a mistake, I had not even tested it and gave me the
same error, is due to the entry point of the "main", as this has not
changed but I hope this works for you. Anyway check the symbol table "nm",
the real-time execution "strace", you can even use gdbserver.

#include <stdio.h>
int main (int argc, char *argv[])
{
printf ("hello world");
return 0;
}


export NDK_ROOT=your_ndk_path
export PATH=$NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin:$PATH
export CC=arm-linux-androideabi-gcc
export LD=arm-linux-androideabi-ld
arm-linux-androideabi-gcc -I$NDK_ROOT/platforms/android-18/arch-arm/usr/include -Wl,-rpath-link=$NDK_ROOT/platforms/android-18/arch-arm/usr/lib -Wl,-L$NDK_ROOT/platforms/android-18/arch-arm/usr/lib -Wl,-lc -o test test.c

If ld return with erros like "... ld: error: cannot open... : No such file or directory"
try this for your losed files:
ln -s $NDK_ROOT/platforms/android-18/arch-arm/usr/lib/crtend_android.o
ln -s $NDK_ROOT/platforms/android-18/arch-arm/usr/lib/crtbegin_dynamic.o

Eclipse does not seem to recognize Native Android code

Eclipse does not work well with C/C++ files. At least, for me it did not.
After some search, I have managed to configure Code::Blocks to support NDK, please see this answer to the question:
Need a simple Linux C++ IDE (Android NDK) .

Issue with build Android NDK project

You need to set the path to android ndk in eclipse.

1. Open C/C++ Perspective.

2. Right click on the project, and select "Properties"

3. Select C/C++ Build => Environment

4. Add PATH environment variable, include path to the android ndk.


Eclipse ADT ... could not be resolved with Android NDK and C files

This may is not be the right way to fix the problem, but you can find the file ${WORKSPACE_LOC}/.metadata/.plugins/com.android.ide.eclipse.ndk/${ProjName}.pathinfo. It is a text file, in simple format. To begin with, try to delete this file, and rebuild the project. If this does not help, you can add

i,d:/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/lib/gcc/arm-linux-androideabi/4.6/include
i,d:/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/lib/gcc/arm-linux-androideabi/4.6/include-fixed
i,D:/Android/android-ndk-r9/platforms/android-14/arch-arm/usr/include

manually (the example above is for Windows).

Update a better workaround is to set up ADT to work with indexer correctly, see Android NDK build, Method could not be resolved or Eclipse compiles successfully but still gives semantic errors.



Related Topics



Leave a reply



Submit