Adem
Adem

Reputation: 9429

compile c++ for specific api level in android

I want to compile my code for specific api level. for example api level 7. and I use ndk-8. is there any option for this ?

now I use ndk-build.cmd command in windows console to compile. and I dont know how can I know which api level is supported.

Upvotes: 1

Views: 1493

Answers (2)

Adem
Adem

Reputation: 9429

excellent reponse, thank you Carl, you saved my life.

I use "APP_PLATFORM := android-7" and it works. when I added this line, compiling gave me an error that a function is not implemented. then, I put its implementation in my code then it works!

I think newer android version has that function but android-7 has not.

the function is wcstombs (it is in stdlib)

and its implementation is

size_t wcstombs(register char *s, register const wchar_t *pwcs, size_t n){
register int i = n;
while (--i >= 0) {
    if (!(*s++ = *pwcs++))
        break;
}
return n - i - 1;
}

thanks

Upvotes: 0

strangefreeworld
strangefreeworld

Reputation: 149

This doesn't appear to be well documented (even in the NDK docs), but if you have an Application.mk (same directory as your root Android.mk), if you have a line APP_PLATFORM := android-7 (or whatever platform version you desire), it will build to that. That isn't documented in the NDK docs for Application.mk. According to the docs, if you put a TARGET_PLATFORM line in the Android.mk, it will use that, but there appears to be information out that that doesn't work.

Upvotes: 3

Related Questions