I am getting this error
/AppData/Local/Temp/ffconf.dkWUWsGo.c:1:20: fatal error: newlib.h: No such file or directory
#include <newlib.h>
while compiling for ffmpeg.
check_cpp_condition newlib.h defined _NEWLIB_VERSION check_cpp BEGIN
/tmp/ffconf.dkWUWsGo.c
1 #include
2 #if !(defined _NEWLIB_VERSION)
3 #error "unsatisfied condition: defined _NEWLIB_VERSION"
4 #endif END /tmp/ffconf.dkWUWsGo.c D:/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gcc
--sysroot=D:/android-ndk-r10b/platforms/android-8/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a -march=armv7-a -std=c99 -E -o /tmp/ffconf.BMIcTDua.o /tmp/ffconf.dkWUWsGo.c C:/Users/vmewada/AppData/Local/Temp/ffconf.dkWUWsGo.c:1:20: fatal
error: newlib.h: No such file or directory #include
^ compilation terminated.
From the path you provided, I guess the file is not present there anymore, because the Temp folder is used for temporary files. Probably you opened an archive (.zip, .rar, .tar, .jar), and after you closed it, the temporary files were deleted. Extract the files to a permanent directory from where you can use them.
As far as I understand from the error log you are trying to cross compile FFmpeg for Android, but I am not sure if Android NDK has a prebuilt newlib version shipped with it. You could check the corresponding platform directory in NDK if it has the include or library, but my assumption is that you will have to build newlib for ARM before you can do this. Btw - last time I compiled FFmpeg for Android I didn't have the issues you got - are you using a correct target? Maybe the newlib is imported because of a wrong architecture.
Related
I have an Android application, developed with Android Studio, that is using a very old build system - NDK 14 with CMake 3.6 and AGP 3.5. I'm trying to update it to NDK 18 (I eventually want to update it to latest NDK, but baby steps) using CMake 3.18.1 and AGP 4.2.2 with Gradle 6.7.1, but the build fails due to errors finding a system include file asm/types.h.
Looking at the clang++ compile command that CMake generates, it is clearly missing the ${SYSROOT}/usr/include/<platform-abi> directory.
My CMake (which worked well for NDK 14 with CMake 3.6.1) has these lines:
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL arm64-v8a)
include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
elseif(${CMAKE_ANDROID_ARCH_ABI} STREQUAL x86_64)
include_directories(${ANDROID_SYSROOT}/usr/include/x86_64-linux-android)
endif()
Running CMake with --trace-expand, I can see it correctly parses those lines:
…
… arm64Release|arm64-v8a :/home/…/myapp/mynativelib/CMakeLists.txt(5):
if(arm64-v8a STREQUAL arm64-v8a )
… arm64Release|arm64-v8a :/home/…/myapp/mynativelib/CMakeLists.txt(6):
include_directories(/home/…/Android/Sdk/ndk/18.1.5063045/sysroot/usr/include/aarch64-linux-android )
…
But the build.ninja file generated does not have this include directory - it contains compile directives that look like so:
build CMakeFiles/mynativelib.dir/home/…/mynativelib/MyClass.cpp.o: \
CXX_COMPILER__mynativelib_Debug /home/…/mynativelib/MyClass.cpp || \
cmake_object_order_depends_target_mynativelib
DEFINES = -DANDROID -DCMAKE_BUILD_TYPE=Debug -DDEBUG -DMIXIT=0 -DNDEBUG -DRELEASE=0 … -D__GXX_EXPERIMENTAL_CXX0X__ -D__STDC_CONSTANT_MACROS
DEP_FILE = CMakeFiles/mynativelib.dir/home/…/mynativelib/MyClass.cpp.o.d
FLAGS = -std=c++14 -fno-stack-protector -ffor-scope -fexceptions -O0 -fno-limit-debug-info \
-fPIC -fno-stack-protector -fpic -ffunction-sections -funwind-tables -no-canonical-prefixes \
-Os -fomit-frame-pointer -fomit-frame-pointer -UNDEBUG -fno-omit-frame-pointer -Ijni -Wformat \
-Wa,--noexecstack -fno-stack-protector -std=c++14
INCLUDES = -I/home/…/Android/Sdk/ndk/18.1.5063045/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/include \
-I../../../../../../../some-custom-include-from-cmake \
-isystem /home/…/Android/Sdk/ndk/18.1.5063045/sources/cxx-stl/llvm-libc++/include
-isystem /home/…/Android/Sdk/ndk/18.1.5063045/sources/cxx-stl/llvm-libc++abi/include
OBJECT_DIR = CMakeFiles/mynativelib.dir
OBJECT_FILE_DIR = CMakeFiles/mynativelib.dir/home/…/mynativelib
I can see that the build command include the some-custom-include-from-cmake include directory, that is added in my CMakeLists.txt file, as well as all the cxx-stl/llvm-libc++ includes that are also added in the CMakeLists.txt file, but the /usr/include/<android-abi> platform include dir is missing.
Even if I use the include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android) command without the if check, right near where the other include_directories() commands that do make it into the build file, it is still missing from the build file. I even tried to add the -I flag directly using set(CMAKE_CXX_FLAGS) and that didn't cause the required include dir to be listed.
OTOH, if I change the include_directories(${ANDROID_SYSROOT}…) to be something that doesn't start with ${ANDROID_SYSROOT}, or points to a non-existing directory - then whatever I put there does make it to the build.ninja file.
Looks like something is very purposefully removing include directories that are in ${ANDROID_SYSROOT} maybe?
Looking in Android NDK r12, I can see that there are differences in the header files under platforms/android-{API level}/{arch}/usr/include/sys. For API levels 19 and below, the file exec_elf.h exists, but appears to have been removed after that. There are a number of other differences where files were added or removed, but I'm interested in exec_elf.h because it defines a particular macro:
#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
This macro is used in the ICU source, and my cross-compiled build of ICU fails if I use a toolchain with the API target set to anything after 19. The build fails with these errors:
arm-linux-androideabi-clang ... icu/source/tools/toolutil/pkg_genc.c
icu/source/tools/toolutil/pkg_genc.c:869:13: warning: implicit declaration of function 'ELF64_ST_INFO' is invalid in C99 [-Wimplicit-function-declaration]
ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
^
icu/source/tools/toolutil/pkg_genc.c:869:13: error: initializer element is not a compile-time constant
ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
^~~~~~~~~~~~~~~~~~~
icu/source/tools/toolutil/pkg_genc.c:987:13: error: initializer element is not a compile-time constant
ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
The compile line is as follows:
android-toolchain/bin/arm-linux-androideabi-clang -D_REENTRANT -DU_HAVE_ELF_H=1 \
-DU_HAVE_ATOMIC=1 -Iicu/source/common -Iicu/source/i18n \
-DU_BUILD="x86_64-apple-darwin15.2.0" -DU_HOST="arm-unknown-linux-androideabi" \
-DU_CC="android-toolchain/bin/arm-linux-androideabi-clang" \
-DU_CXX="android-toolchain/bin/arm-linux-androideabi-clang++" \
-DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit \
-DU_ATTRIBUTE_DEPRECATED= -DU_TOOLUTIL_IMPLEMENTATION -O3 -O2 -pipe -fsigned-char \
-fPIC -D__ANDROID__ -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -std=c99 \
-Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c \
-DPIC -fPIC -o pkg_genc.o icu/source/tools/toolutil/pkg_genc.c
I can get the build to succeed by adding the definition of ELF64_ST_INFO at the top of pkg_genc.c, so I'm pretty positive that the lack of the definition of this macro in the Android system headers is the issue. Does anyone know why this changed across API levels? Is this difference intentional, or is this a bug in the NDK?
This was a bug in the NDK. To illustrate the importance of filing bugs, this was filed 8 hours ago and we already have a fix going through presubmit: https://github.com/android-ndk/ndk/issues/377. The fix should be available in r15 beta 2, due out at I/O (17 May).
I am trying to develop on android NDK.
I actually have a project + subfolder with modules (compiled as static libraries) and linked together with the main project files (libs .a + main object .o --> executable). Everything done via ndk-build.
I am trying to make use of constructors, after digging for some hours I figured out that constructors are NOT called as long as a function of that lib (.o) is not invoked.
e.g.
__attribute__ ((__constructor__))
void pre_func(void) {
printf("pre_func2\n");
}
void my_init(){
printf ("tutto funge!");
//return 0;
}
called only when (and before) my_init(); is explicitly invoked in test.c
$ adb shell /data/local/tmp/test
pre_func2
tutto funge!
now, my issue is very simple. By architecture I need some modules I prepared to be initialized when the object is loaded... I searched several stuff (--init, _init()) none of them helps.
Since the same code on standard linux (glibc and no bionic linker) looks to work fine, is there something wrong in my compilation gcc statement which avoids the constructor to be executed at .a loading time? how can I solve?
Compile thumb :
modules <= libtest.c
/opt/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm- linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi/objs/modules/libtest.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Ijni/modules -DANDROID -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -Wa,--noexecstack -I/opt/android-ndk-r8e/platforms/android-3/arch-arm/usr/include -c jni/modules/libtest.c -o ./obj/local/armeabi/objs/modules/libtest.o
StaticLibrary : libmodules.a
rm -f obj/local/armeabi/libmodules.a
/opt/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar crs ./obj/local/armeabi/libmodules.a ./obj/local/armeabi/objs/modules/libtest.o ./obj/local/armeabi/objs/modules/module.o
I guess that the problem is that if some .o is not called from test.c, it is not linked into the test executable. That's how the liner treats static libraries (.a files). To force all compilation units (a.k.a. .o files) to be present in the executable, use
-Wl,-whole-archive libmodules.a -Wl,-no-whole-archive
for building. You can achieve this in NDK by specifying
LOCAL_WHOLE_STATIC_LIBRARIES := modules
but I must confess that I have never tried this with $(BUILD_EXECUTABLE). It works fine for $(BUILD_SHARED_LIBRARY). If something goes wrong, simply write
LOCAL_LDFLAGS := -Wl,-whole-archive $(PATH_TO_LIBMODULES)/libmodules.a -Wl,-no-whole-archive
and don't forget to set PATH_TO_LIBMODULES correctly.
I have spent half a day killing the error. I'm really bored and teared.
The project is converting iPhone App to Android apk by Stella SDK.
The IDE is xCode 4.6.
CompileC build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/Objects-normal/x86_64/main.o main.m normal x86_64 objective-c com.yeecco.compilers.android.clang.1.0
cd /Users/anna/samples/GLSprite
setenv LANG en_US.US-ASCII
/opt/StellaSDK/bin/android-clang -x objective-c -arch x86_64 -fmessage-length=0 -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.8 -g -Wno-sign-conversion -I/Users/anna/samples/GLSprite/build-arm-google-android/Debug/include -I/opt/StellaSDK/arm-google-android/usr/include -I/opt/StellaSDK/arm-google-android/System/Library/Frameworks/cocos2d.framework/Headers -I/opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaMedia.framework/Headers -I/opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaStore.framework/Headers -I/Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/DerivedSources/x86_64 -I/Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/DerivedSources -F/Users/anna/samples/GLSprite/build-arm-google-android/Debug -F/opt/StellaSDK/arm-google-android/System/Library/Frameworks -stella_target arm-google-android -D__STELLA_NANDROID -D__STELLA_VERSION_MAX_ALLOWED -MMD -MT dependencies -MF /Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/Objects-normal/x86_64/main.d -c /Users/anna/samples/GLSprite/main.m -o /Users/anna/samples/GLSprite/build-arm-google-android/GLSprite-android.build/Debug/GLSprite.build/Objects-normal/x86_64/main.o
warning: unknown warning option '-Wreceiver-is-weak' [-Wunknown-warning-option]
warning: unknown warning option '-Wint-conversion' [-Wunknown-warning-option]
warning: unknown warning option '-Wenum-conversion' [-Wunknown-warning-option]
In file included from /Users/anna/samples/GLSprite/main.m:49:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:17:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaKit.framework/Headers/StellaKit.h:7:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/StellaKit.framework/Headers/SVAcceleration.h:5:
In file included from /opt/StellaSDK/arm-google-android/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:11:
In file included from /usr/include/sys/types.h:78:
/usr/include/machine/types.h:37:10: fatal error: 'arm/types.h' file not found
#include "arm/types.h"
^
3 warnings and 1 error generated.
Command /opt/StellaSDK/bin/android-clang failed with exit code 1
The error message is shown because the compiler is looking for types.h in arm folder. If you could provide the file, the compiler will not show this error and continue. Check the documentation of StellaSDK, they should have a "guide" on how to cross compile
I'm just getting to know nme haxe developing, I'm currently using flashdevelop. I have a problem when building a sample app (piratepig) under android platform. Lots of "no such file or directory". Everything seems fine when I choose windows, Html5, or flash platforms.
Here's the output:
Running process: C:\Program Files (x86)\FlashDevelop\Tools\fdbuild\fdbuild.exe "C:\Users\Valentin\Desktop\PiratePig\Pirate Pig.hxproj" -ipc 2a666e48-3f38-4abd-b63a-25219cb72cf4 -version "2.10" -compiler "C:\Motion-Twin\Haxe" -library "C:\Program Files (x86)\FlashDevelop\Library" -target "android"
Building Pirate Pig
haxelib run nme build C:\Users\Valentin\Desktop\PiratePig\project.nmml android -debug
haxelib run hxcpp Build.xml haxe -Ddebug -Dactuate -Dandroid -Dcpp -Ddebug -Dhaxe_208 -Dhaxe_209 -Dhaxe_210 -Dmobile -Dnme -Dnme_install_tool -Dsys -Dtrue
Creating hxcpp.h.gch...
arm-linux-androideabi-g++ -Iinclude --sysroot=C:\Development\Android NDK/platforms/android-5/arch-arm -IC:\Development\Android NDK/sources/cxx-stl/gnu-libstdc++/include -IC:\Development\Android NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -DHXCPP_DEBUG -DHXCPP_VISIT_ALLOCS -Dhaxe_210 -IC:\Motion-Twin\Haxe\lib\hxcpp\2,10//include -Iinclude -fpic -fvisibility=hidden -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -D_LINUX_STDDEF_H -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer -fexceptions -fno-strict-aliasing -finline-limit=10000 -DANDROID -Wa,--noexecstack -O0 -DNDEBUG -c -frtti -o hxcpp.h.gch C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hxcpp.h
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hxcpp.h:13:20: error: typeinfo: No such file or directory
In file included from C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hxcpp.h:170:
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/Array.h:195:21: error: algorithm: No such file or directory
In file included from C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hxcpp.h:162:
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hx/Object.h: In member function 'void hx::ObjectPtr<O>::CastPtr(hx::Object*)':
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hx/Object.h:143: error: must #include <typeinfo> before using typeid
In file included from C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hxcpp.h:170:
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/Array.h: In member function 'void Array_obj<ELEM_>::sort(Dynamic)':
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/Array.h:388: error: 'sort' is not a member of 'std'
In file included from C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/hxcpp.h:171:
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/Class.h: In function 'bool hx::TCanCast(hx::Object*)':
C:\Motion-Twin\Haxe\lib\hxcpp\2,10//include/Class.h:139: error: must #include <typeinfo> before using typeid
Called from ? line 1
Called from BuildTool.hx line 1265
Called from BuildTool.hx line 554
Called from BuildTool.hx line 591
Called from BuildTool.hx line 710
Called from BuildTool.hx line 739
Called from BuildTool.hx line 153
Uncaught exception - Error creating pch: 1 - build cancelled
Error : Build failed
Build halted with errors (haxelib.exe).
Done(1)
Does anyone have a clue, what could be wrong? I tried running a simple helloworld app in eclipse (so that i can be sure that its related to haxe, and nme), but the helloword app works perfectly.
did you use NME 3.5.3 or higher?
then you need to switch to hxcpp 2.10.3 . it will solve the problem. try to update the hxcpp through haxelib with this command
haxelib upgrade
The problem was solved a long time ago, through some hit on google. I cant find it now, but it was something about the NDK directory, i had to move or copy some files in the structure.
It might have been something like this
As far as I remember it was something similar to this (answer posted by Andy on openfl):
Copy the files from
${ANDROID_NDK_ROOT}\sources\cxx-stl\gnu-libstdc++\4.4.3\ to
${ANDROID_NDK_ROOT}\sources\cxx-stl\gnu-libstdc++\
Here's the link to his answer, and some similar questions above:
http://www.openfl.org/developer/forums/installing-openfl/beginner-questions-android-build-failed/