c++ - ndk-build : CreateProcess: make (e=87): The parameter is incorrect

标签 c++ windows android-ndk createprocess

在 Windows 平台上使用 NDK 构建静态库时出现错误:

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....

所有源文件构建成功,编写目标文件时出现此错误。

在 Ubuntu 中构建此项目时,我没有收到此错误,它仅在 Windows 上发生。

我想我找到了 问题:CreateProcess 的第二个参数Win API 函数 lpCommandLine 的最大长度为 32,768 个字符。但就我而言,它超过 32,768 个字符。

我该如何解决这个问题?

最佳答案

也许要在您的 Android.mk 中设置的 LOCAL_SHORT_COMMANDS 标志可以帮助您。它旨在克服 Windows 命令可以处理的字符数限制。

根据$(NDK文件夹)/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.

希望这会有所帮助!

关于c++ - ndk-build : CreateProcess: make (e=87): The parameter is incorrect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12598933/

相关文章:

Windows 命令行 : open file with active process?

如果没有 project.properties 文件,Android JNI 将无法编译

c++ - C++ 中的可变大小数组

c++ - 抽象类的迭代器

c++ - 如何在 Visual C++ 中将数组元素向右移动并用字符串替换移动后的索引

windows - 检测 C/C++ 中字符串的编码

c - 进程返回 -1073741819 <0xC0000005>

c# - Xamarin 应用程序无法在 Release模式下工作

android - 将 jlong​​ 转换为 long 是否安全?

c++ - 如何创建一个添加数字的模板函数