Input path limit for Android ndk source file - android

Is there a known limit on the path for the Android ndk input files? I've run into an issue where the input path is over 155 characters the android g++ command fails to find the file.
The local path back down to my base directory is quite deep, in a few cases I have a full path back to a source file in the jni project making the path a bit long, though 155 doesn't seem like a very high limit.
LOCAL_PATH := $(call my-dir)/../../../../../../../../../..
Here is an example of a failure, at 155 characters:
/cygdrive/c/java/Android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -c jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/./././VECodecG723/VECodecG723.cpp
arm-linux-androideabi-g++.exe: error: jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/./././VECodecG723/VECodecG723.cpp: No such file or directory
arm-linux-androideabi-g++.exe: fatal error: no input files
And a success case, at 153 characters:
/cygdrive/c/java/Android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -c jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/././VECodecG723/VECodecG723.cpp
jni/VECodecG723/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/../gen/././VECodecG723/VECodecG723.cpp:26:17: fatal error: jni.h: No such file or directory
#include <jni.h>
The repeating ../gen is just for this sample, the actual path contains 10 ../ and then the full path back to the file.
I've tried the paths with the regular g++ compiler and it does not fail because of the path length. I have also tried this in a Windows command shell with the android g++ and it has the same issue.
Is there anything I can do short of renaming my folders.

I took another look at this and figured it out. I was running into the max path length for Windows, 260 characters or so. When I added the base path forming an absolute path to the source file the breaking point was around the windows max. No good way around this other than to build on Linux or a Mac.

Related

Can't compile Chromium for android on Debian 9 - Unable to create file. File name too long

I am trying to compile chromium for android on Debian 9 and I get this error, can someone help me on this?
dacod#phoenix:~/Devel/chromium/src$ ninja -C out/Default cast_shell_apk
ninja: Entering directory `out/Default'
[0/21317] ACTION //third_party/WebKit/Source/bindings/modules/v8:generate...snapshot_external_references(//build/toolchain/android:android_clang_arm)
ninja: error:
WriteFile(__third_party_WebKit_Source_bindings_modules_v8_generate_v8_context_snapshot_external_references___build_toolchain_android_android_clang_arm__rule.rsp):
Unable to create file. File name too long
ninja: build stopped: .
The file system you are building on does not support name sizes long enough to accommodate the 150 character filename:
__third_party_WebKit_Source_bindings_modules_v8_generate_v8_context_snapshot_external_references___build_toolchain_android_android_clang_arm__rule.rsp
Typical file systems will support 255 character file names. Here is a reference:
https://serverfault.com/questions/9546/filename-length-limits-on-linux
However, eCryptfs only supports 143 character file names if it is also configured to encrypt the file names themselves [source]. Are you building in your home folder and is it encrypted? If so, this may be the reason. To check the file name size, run the following in your build folder:
$ getconf NAME_MAX .
143
If it is not 255 you may be building on an ecryptfs partition. Try building in /tmp instead, as it may not be encrypted. You can check this with:
$ getconf NAME_MAX /tmp
255

android studio, c++, windows, filename too long

I'm building c++ application for android using Android Studio 2.3.3. Build fails with error:
Fatal error: can't create
CMakeFiles/kore.dir/C_/ab/android-native-build/Sources/src/banan/server/serverData/ServerCompound_banan_server_serverdata_ListValue_IdInt_banan_server_serverdata_ServerCompound_serverdata_ServerAchieve.cpp.o:
No such file or directory clang++.exe: error: assembler command failed
with exit code 1 (use -v to see invocation)
The directory in which this file should be created exists and some other files were successfully created there.
I think this is because of path is too long. I've seen such messages previously and moving project to another directory with shorter path have solved the issue. But now I've already done this.
shorter your project location because path maximum 256 char long is accepted.

How to set temporary directory when building cyanogenmod

I am trying to build cyanogenmod, but the build fails with the following. My drive on /mnt has plenty of space, however the root-partition where /tmp resides has less space, so I assume this happens while writing a temporary file.
Therefore I would like to redirect the temporary directory for this to somewhere under /mnt as well, how can I do this in cyanogenmod/Android build system? I tried setting TMP and TEMP but they don't seem to have any effect.
Package OTA: /mnt/android/system/out/target/product/oneplus3/cm_oneplus3-ota-178d4560f4.zip
unzipping target target-files...
running: unzip -o -q /mnt/android/system/out/target/product/oneplus3/obj/PACKAGING/target_files_intermediates/cm_oneplus3-target_files-178d4560f4.zip -d /tmp/targetfiles-RM6VsH
--- target info ---
...
cache_size = (int) 268435456
...
recovery_size = (int) 67108864
...
userdata_size = (int) 57436708864
(using device-specific extensions from target_files)
loaded device-specific extensions from /tmp/targetfiles-RM6VsH/META/releasetools.py
Warning: could not find RADIO/filesmap in <zipfile.ZipFile object at 0x2b4193f91fd0>.
using prebuilt recovery.img from BOOTABLE_IMAGES...
using system.img from target-files
Total of 770048 4096-byte output blocks in 2698 input chunks.
Generating digraph...
Finding vertex sequence...
Reversing backward edges...
0/0 dependencies (0.00%) were violated; 0 source blocks stashed.
Improving vertex order...
Revising stash size...
Total 0 blocks are packed as new blocks due to insufficient cache size.
Reticulating splines...
Traceback (most recent call last):
File "./build/tools/releasetools/ota_from_target_files", line 1772, in <module>
main(sys.argv[1:])
File "./build/tools/releasetools/ota_from_target_files", line 1727, in main
WriteFullOTAPackage(input_zip, output_zip)
File "./build/tools/releasetools/ota_from_target_files", line 664, in WriteFullOTAPackage
system_diff = common.BlockDifference("system", system_tgt, src=None)
File "/mnt/android/system/build/tools/releasetools/common.py", line 1302, in __init__
b.Compute(self.path)
File "/mnt/android/system/build/tools/releasetools/blockimgdiff.py", line 299, in Compute
self.ComputePatches(prefix)
File "/mnt/android/system/build/tools/releasetools/blockimgdiff.py", line 618, in ComputePatches
new_f.write(piece)
IOError: [Errno 28] No space left on device
make: *** [/mnt/android/system/out/target/product/oneplus3/cm_oneplus3-ota-178d4560f4.zip] Error 1
make: Leaving directory `/mnt/android/system'
Update: I found a workaround by editing /mnt/android/system/build/tools/releasetools/common.py and setting a temp-dir manually with something like tmpdir = tempfile.mkdtemp(dir='/mnt/tmp') at line 1299, according to documentation mkdtemp should use TMP and TEMP, however that seems to not have worked for me here! Python is at version 2.7.6.
To set the TMPDIR environment variable, specify a directory that is accessible to the user ID that runs the replication or publishing programs. Ensure that files cannot be deleted by other user IDs.
For example, the following command specifies the /home/repldba/tempfiles/ directory:
export TMPDIR=/home/repldba/tempfiles/

Error while trying to compile android kernel in ubuntu

I'm trying to compile a Android Kernel from source and I have downloaded all the right packages to do it but for some reason I get this error:
arm-linux-androideabi-gcc: error: unrecognized command line option '-mgeneral-regs-only'
/home/livlogik/android/kernel/H901BK_L_Kernel/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:858: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
I have the latest NDK and I'm using Ubuntu 15.10 64bit if this helps.
Here is where I have the NDK and kernel:
NDK ---- /home/livlogik/android/ndk/
Kernel ---- /home/livlogik/android/kernel/H901bk_L_Kernel/
If someone could help me that would be great. Sorry if this was already posted I could find a answer to it.
Thanks,
Zach
As it can be seen from build error message:
drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c:20:27: fatal error: ./mh1/msm_mh1.h: No such file or directory
#include <./mh1/msm_mh1.h>
compiler just can't find msm_mh1.h file. This is because the path specified for #include directive isn't correct. Most probably it's typo: instead ./ there should be ../.
To fix that error, in drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c file change this line:
#include <./mh1/msm_mh1.h>
to this line
#include "../mh1/msm_mh1.h"
After this make command should work fine. Also, kernel image file will be available at arch/arm64/boot, and it's not zImage as stated in documentation, it's actually Image.gz. Uncompressed kernel image is Image file.
Update
Answering your question in comments:
Is there any way to make it compress into a zImage?
From Documentation/arm64/booting.txt:
The AArch64 kernel does not currently provide a decompressor and
therefore requires decompression (gzip etc.) to be performed by the boot
loader if a compressed Image target (e.g. Image.gz) is used. For
bootloaders that do not implement this requirement, the uncompressed
Image target is available instead.
Basically zImage is just gzipped and self-extracted Image. So zImage file consists of program for unpacking gzip archive in the beginning, followed by gzipped Image, and when kernel is run by bootloader its unpacking itself (hense "self-extracted" term) and then start running.
...So I can make it flashable
In case of arm64, you don't have zImage, so most likely you need to use Image file (which acts in the same way, but only its size is bigger). You can create boot.img from Image file and built AFS ramdisk (using mkbootimg tool) and then just do fastboot flash boot boot.img. Refer to this documentation for example. Of course for your platform some things can be different, so try to find instructions for your platform.
You have to install the right toolchain:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
And configure the Makefile appropriately
The wrong toolchain is at
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-android-4.9

compile ffmpeg with android ndk r5b

compile ffmpeg with android ndk r5b.
ffmpeg 0.6.1
android ndk r5b
cygwin 1.7
build reference url : http://www.cnblogs.com/scottwong/archive/2010/12/17/1909455.html
but, ffmpeg ./configure result error! (below config.err file)
check_cc
BEGIN /tmp/ffconf.GlDiY1P8.c
1 int main(void){ return 0; }
END /tmp/ffconf.GlDiY1P8.c
/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/windows/bin/arm-eabi-gcc -fPIC -DANDROID -c -o /tmp/ffconf.1kQLpGaU.o /tmp/ffconf.GlDiY1P8.c
arm-eabi-gcc.exe: /tmp/ffconf.GlDiY1P8.c: No such file or directory
arm-eabi-gcc.exe: no input files
C compiler test failed.
so, i just try test code.
// test.c code
int main(){
return 0;
}
/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/windows/bin/arm-eabi-gcc -fPIC -DANDROID -c -o ./test.o ./test.c
ok!!!! no problem.
but,
cp ./test.c /tmp (copy to /tmp)
/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/windows/bin/arm-eabi-gcc -fPIC -DANDROID -c -o ./test.o /tmp/test.c
arm-eabi-gcc.exe: /tmp/test.c: No such file or directory
arm-eabi-gcc.exe: no input files
fail!!!
difference is only file path. /tmp directory exist, and permission is right. /home/test.c is same result.
what's wrong?
I have had a hard time to get it working in Windows, but finally I've managed to do it!
The previous posts were correct - there's a problem with Cygwin paths and Windows paths.
I have tried the solution described in the post above as the very first thing, but it was not working. Finally I've understand the reason: even if you put into your build_android.sh file the Windows path, the config for FFmpeg still contains the wrong path.
So in my case I have changed partially the config file in FFmpeg root directory from:
#set temporary file name
: ${TMPDIR:=$TEMPDIR}
: ${TMPDIR:=$TMP}
: ${TMPDIR:=/tmp}
to this:
# set temporary file name
#: ${TMPDIR:=$TEMPDIR}
#: ${TMPDIR:=$TMP}
: ${TMPDIR:=D:/InstallTools/Android/Cygwin_Root/tmp}
After this, I got it compiling.
You don't set the tmp directory. You can set it in /etc/profile or just in the terminal with export TMPDIR=/your/tmp/directory.
Notice:
1. If you compile with cygwin, the directory must be like D:/tmp. You can't use /cygdrive/d/tmp.
2. You must have the permission of the folder.
I could not get this to work either, I had the exact same problem. However I was able to compile using "android-ndk-r4". I am not sure at the moment what is causing the problem but if I ever get around to figuring it out I'll post that too.
So for now workaround is to use ndk r4.
I managed to build it, using NDK R6, cygwin. Indeed, it does not support /cydrive/ paths, simply use paths like windows; example below:
NDK=e:/AndroidSDK/NDK6
PLATFORM=$NDK/platforms/android-9/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows
If you have not solved this problem, check the last part of config.log in the ffmpeg directory; it is most likely a path or CC parameter problem.
I have been having the exact same problem with r6. I have tried Lambage's suggestion with r4 but still could not get this to work.
I have been looking into the problem quite a lot and I think I've discovered the reason.
1)configure is calling the android cross compiler which is a windows .exe file.
2)It is calling it through cygwin which uses unix file naming conventions. E.G /cygdrive/c/directory instead of C:\directory
3)It says in the android NDK toolchain documentation that the cross compilers do NOT accept cygwin style filepaths (source: NDK/docs/STANDALONE_TOOLCHAIN.html):
5.1/ Windows support:
The Windows binaries do not depend on Cygwin. The good news is that they
are thus faster, the bad news is that they do not understand the Cygwin
path specification like /cygdrive/c/foo/bar (instead of C:/foo/bar).
I'm still trying to find a way to do this. If i solve it then I'll come back and edit this post...tbc

Categories

Resources