33

I get an error when build static lib with NDK on Windows platform:

process_begin: CreateProcess( "PATH"\android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ar.exe, "some other commands" ) failed.
make (e=87): The parameter is incorrect.
make: *** [obj/local/armeabi-v7a/staticlib.a] Error 87
make: *** Waiting for unfinished jobs....

All source files build successfully, and this error occur when compose object files.

I don't get this error when build this project in Ubuntu, it occur only on Windows.

I suppose I found the issue: second parameter of CreateProcess Win API function lpCommandLine has max length 32,768 characters. But in my case it is more than 32,768 characters.

How I can solve this issue?

Oleksandr Shtykhno
  • 766
  • 2
  • 7
  • 12

3 Answers3

36

Maybe the LOCAL_SHORT_COMMANDS flag, to be set in your Android.mk, could help you. It is designed to overcome the limitations on the number of characters a Windows command can handle.

According to $(NDK folder)/docs/ANDROID-MK.html:

LOCAL_SHORT_COMMANDS

Set this variable to 'true' when your module has a very high number of sources and/or dependent static or shared libraries. This forces the build system to use an intermediate list file, and use it with the library archiver or static linker with the @$(listfile) syntax.

This can be useful on Windows, where the command-line only accepts a maximum of 8191 characters, which can be too small for complex projects.

This also impacts the compilation of individual source files, placing nearly all compiler flags inside list files too.

Note that any other value than 'true' will revert to the default behaviour. You can also define APP_SHORT_COMMANDS in your Application.mk to force this behaviour for all modules in your project.

NOTE: We do not recommend enabling this feature by default, since it makes the build slower.

Hope this helps!

mbrenon
  • 4,851
  • 23
  • 25
22


Special Thanks to @mbrenon !

Remember to set both of LOCAL_SHORT_COMMANDS(Android.mk) & APP_SHORT_COMMANDS(Application.mk) as the following.

LOCAL_SHORT_COMMANDS := true
APP_SHORT_COMMANDS := true

Hope this helps ! :)

HoseinGhanbari
  • 1,058
  • 1
  • 11
  • 23
  • can we add these lines on the top of others ? and i have multiple adroid.mk files should i add this command in all those files ? – Ahmad Aug 06 '20 at 17:38
  • According to the docs: `You can also define APP_SHORT_COMMANDS in your Application.mk to force this behaviour for all modules in your project`. – mortalis Oct 02 '20 at 08:11
  • And the `LOCAL_SHORT_COMMANDS` variable should be placed after the `include $(CLEAR_VARS)` line. – mortalis Oct 02 '20 at 08:31
1

I was facing same problem and it got resolved when I made below changes

  1. Right click Application -> properties
  2. C/C++ Build
  3. Changed Build directory: ${workspace_loc:/App}/Default to ${workspace_loc:/App}/
tejasD
  • 21
  • 1
  • 1
    There's a character limit, and you shortened the character length of your paths. It's not surprising this would work for you, but is a pretty obvious workaround for paths being too long. – Keith M Jan 27 '17 at 17:45