Porting C program to Android NDK

I start with C / C ++ and Android NDK, and I have a problem creating my own library. My code compiles using MinGW on a CDT, but when I write the same code in a JNI file, an error occurs.

My code is:

int n = 7; int positions[n]; int final_order[n]; memcpy(positions, final_order,sizeof(final_order)); 

The plugin shows me:

 Invalid arguments 'Candidates are: void * memcpy(void *, const void *, ?)' 

This title is from MinGW on the CDT:

 _CRTIMP void* __cdecl __MINGW_NOTHROW memcpy (void*, const void*, size_t); 

This is the title with the Android NDK:

 extern void* memcpy(void *, const void *, size_t); 
+4
c android android-ndk
source share
2 answers

Known indexing issue when using Eclipse for NDK development.

Read about it here: https://code.google.com/p/android/issues/detail?id=33788

Near the bottom there is a reasonable workaround that I myself use:

We want to use the Android GCC toolchain, but change the real tools and change the detection options so that the correct paths and characters are included.

Go to the C / C ++ Buid \ Tool Chain editor

Make sure Android GCC is the selected toolchain and Android Builder is the selected builder.

Click “Select Tools” Select “Allow All Changes” Remove the Android GCC Compiler Add the “GCC C Compiler” and “GCC C ++ Compiler” so that we can index the c and cpp headers.

If you look at Paths and Symbols, you will see that we have the GNU C and GNU C ++ languages, but of course the built-in include paths are incorrect. Fortunately, there is a fix for this.

Go to C / C ++ Build \ Discovery Options Change the area of ​​the discovery profiles to “Configuration”. Make sure that the “Discovery Profile uses“ AndroidPerProjectProfile ”and make sure both boxes are checked.

Then I need to manually add my own include directories and definitions in Project Properties -> C/C++ General -> Paths and Symbols

It is worth noting that your code compiles in order. You can turn off indexing if you want, but if you still need the benefits of indexing, you'll have to work around this problem.

+8
source share

Another workaround is:

to open the perspective of android native ,

to right click your project in project navigator ,

and click on the index options to rebuild the indexes.

0
source share

All Articles