LOCAL_SHORT_COMMANDS causes compilation to fail

250 views
Skip to first unread message

Little Coding Fox

unread,
Oct 17, 2014, 6:58:47 AM10/17/14
to andro...@googlegroups.com
I'm running ndk-build on Windows, and I've got something compiling but I reach the CreateProcess character limit. However, setting LOCAL_SHORT_COMMANDS to true makes the compilation fail completely, since for some reason it stops adding the include directories or something like that (e.g., can't find headers I added to the include directories). Does anyone have any idea what might be causing the problem? If I don't set LOCAL_SHORT_COMMANDS to true, it'll compile, but fail at the linking step due to the character limit.

Makefiles: http://pastebin.com/q9PE7dCt

Little Coding Fox

unread,
Oct 17, 2014, 7:09:08 AM10/17/14
to andro...@googlegroups.com
Forgot to mention I'm using the latest NDK (r10b)

Kevin Dixon

unread,
Apr 9, 2015, 2:39:53 PM4/9/15
to andro...@googlegroups.com
I am experiencing this problem (or similar) trying to build OpenSSL libcrypto_static. When I set LOCAL_SHORT_COMMANDS to true, the compile fails because something is wrong with the macro expansion in cversion.c -- it works fine building libcrypto_static with LOCAL_SHORT_COMMANDS to false)

dom...@chasing-carrots.com

unread,
Jul 1, 2015, 3:56:33 PM7/1/15
to andro...@googlegroups.com
I just lost a few hours on this one, so even if this is an old topic here is my solution for posterity:

TLDR: The short solution for OpenSSL:
Edit android-config.mk in the openssl base directory, change
# Directories
LOCAL_CFLAGS += \
  -DOPENSSLDIR="\"/system/lib/ssl\"" \
  -DENGINESDIR="\"/system/lib/ssl/engines\""

to

# Directories
LOCAL_CFLAGS += \
  -DOPENSSLDIR=\\\"/system/lib/ssl\\\" \
  -DENGINESDIR=\\\"/system/lib/ssl/engines\\\"

For the interested or the ones with different LOCAL_SHORT_COMMANDS problems the explanation:
LOCAL_SHORT_COMMANDS creates temp files with the commandline options for every command in the build process and feeds those files to the respective command (gcc for example). Launch the ndk-build command with V=1 (verbose mode) and you'll see the steps involved. You can also see where those files get created, so you can have a look at them if something is not working as expected. In the OpenSSL case I had a look at the obj\local\armeabi-v7a\objs\crypto_static\crypto\cversion.o.cflags file and saw that the OPENSSLDIR and ENGINESDIR defines were missing the backslash in front of the quotation mark. So the gcc command just omitted the quotation marks and the define wasn't a string anymore. The \\\" in the makefile resulted in a \" in the .cflags file, which was exactly what gcc needed.

There you have it, I hope this saves somebody my frustrations :)
Cheers
Reply all
Reply to author
Forward
0 new messages