Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8818211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:03:28+00:00 2026-06-14T05:03:28+00:00

I know I can use LOCAL_CFLAGS to pass arguments to the compiler. However, ndk-build

  • 0

I know I can use LOCAL_CFLAGS to pass arguments to the compiler. However, ndk-build is inserting options after my LOCAL_CFLAGS, and therefore they take precedence. For example, I want to specify -Ofast, but ndk-build adds -O2 after my own flags, and since only the last option is the one that has any effect, I’m unable to test my code with certain optimization flags set.

Is there any way to either force my LOCAL_CFLAGS to be the last options on the build command, or to disable ndk-build from using certain flags?

For example, my LOCAL_CFLAGS is set to:

-Wall -Wno-psabi -Ofast -D CP_USE_DOUBLES=0 -D USE_CHIPMUNK

And the call to g++ that ndk-build makes is:

/Library/Android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi-v7a/objs/native-activity/Main.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-exceptions -fno-rtti -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni -Ijni/Chipmunk/include/chipmunk -I/Library/Android/android-ndk-r8b/sources/android/native_app_glue -I/Library/Android/android-ndk-r8b/sources/cxx-stl/stlport/stlport -I/Library/Android/android-ndk-r8b/sources/cxx-stl//gabi++/include -Ijni -DANDROID -Wall -Wno-psabi -Ofast -D CP_USE_DOUBLES=0 -D USE_CHIPMUNK -Wa,--noexecstack -frtti -O2 -DNDEBUG -g -I/Library/Android/android-ndk-r8b/platforms/android-9/arch-arm/usr/include -c jni/Main.cpp -o ./obj/local/armeabi-v7a/objs/native-activity/Main.o

There’s a lot in there, but specifically notice that it first specifies -Os, then there’s my -Ofast, and then after that there’s -O2. Why it specifies -Os if it’s going to later say -O2, I don’t know, but I’m frustrated my -Ofast is being overridden.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:03:29+00:00Added an answer on June 14, 2026 at 5:03 am

    Add

    APP_CFLAGS += -Ofast
    

    to your Application.mk.

    It will not stop NDK from adding -O2 but it will place your flag after the NDK’s.
    This works for me with NDK r8b.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can use install-data-hook to do anything I want after my data
How can I build libsdl using the Android NDK's standalone toolchain? I can't use
I know I can use the -n flag in git grep to show the
I know you can use -fno-objc-arc flag to disable ARC for files that NOT
I know you can use source control software for source code, but can you
I know I can use the ActionView helper strip_tags method in my views to
I know I can use something like User.sort {|a, b| a.attribute <=> b.attribute} or
I know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
I know I can use the RODBC library for accessing excel (.xls) docs from
You know we can use message queues with the function mq_receive(); what is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.