简体   繁体   中英

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.

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM