Cross compiling boost for android using conan - android

I was trying to cross compile some conan libraries using android ndk from my linux machine.
When trying to cross compile boost i get build failure error. Other conan packages cross compile perfectly except boost. I have added the conan profile and err log.
My conan profile:
include(default)
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=libc++
compiler.version=12
os=Android
os.api_level=21
[build_requires]
[options]
[env]
ANDROID_NDK_ROOT=/home/local/Downloads/android-ndk-r23
WARN: replace_in_file didn't find pattern '$(>) > $(<)' in '/home/local/.conan /data/boost/1.76.0/_/_/source/source_subfolder/libs/stacktrace/build/Jamfile.v2' file.
WARN: replace_in_file didn't find pattern '/* thread_local */' in '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/boost/stacktrace/detail/libbacktrace_impls.hpp' file.
WARN: replace_in_file didn't find pattern '/* static __thread */' in '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/boost/stacktrace/detail/libbacktrace_impls.hpp' file.
boost/1.76.0: WARN: Patching user-config.jam
boost/1.76.0: WARN:
using zlib : 1.2.11 : <include>"/home/local/.conan/data/zlib/1.2.11/_/_/package/18bbcddf275ee23aa172cdc6dbfa549e2411acfd/include" <search>"/home/local/.conan/data/zlib/1.2.11/_/_/package/18bbcddf275ee23aa172cdc6dbfa549e2411acfd/lib" <name>z ;
using bzip2 : 1.0.8 : <include>"/home/local/.conan/data/bzip2/1.0.8/_/_/package/a765640a31d963ba8d5612cab2f1811597d3de80/include" <search>"/home/local/.conan/data/bzip2/1.0.8/_/_/package/a765640a31d963ba8d5612cab2f1811597d3de80/lib" <name>bz2 ;
using "clang-linux" : : :
<compileflags>"-I/home/local/.conan/data/libbacktrace/cci.20210118/_/_/package/18bbcddf275ee23aa172cdc6dbfa549e2411acfd/include" <linkflags>"-L/home/local/.conan/data/libbacktrace/cci.20210118/_/_/package/18bbcddf275ee23aa172cdc6dbfa549e2411acfd/lib" ;
boost/1.76.0: Cross building, detecting compiler...
boost/1.76.0: Cross building flags: []
boost/1.76.0: WARN: b2 -q numa=on target-os=android architecture=arm address-model=64 binary-format=elf abi=aapcs --layout=system --user-config=/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=on boost.locale.iconv.lib=libc threading=multi visibility=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave toolset=clang-linux pch=on cxxflags="-fPIC -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/home/local/.conan/data/boost/1.76.0/_/_/package/1e5ed3b96aff577e610fddd01bd296a709542e8c -j12 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/local/.conan/data/boost/1.76.0/_/_/build/1e5ed3b96aff577e610fddd01bd296a709542e8c"
notice: found boost-build.jam at /home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/boost-build.jam
notice: loading B2 from /home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/bootstrap.jam
warning: mismatched versions of B2 engine and core
warning: B2 engine (b2) is 4.5.0
warning: B2 core (at /home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src) is 4.4-git
notice: Searching '/etc' '/home/local' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/kernel' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/util' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/tools' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/contrib' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/.' for site-config configuration file 'site-config.jam'.
notice: Configuration file 'site-config.jam' not found in '/etc' '/home/local' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/kernel' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/util' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/tools' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/contrib' '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/.'.
notice: Loading explicitly specified user configuration file:
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/user-config.jam
notice: Searching '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build' for user-config configuration file 'user-config.jam'.
notice: Loading user-config configuration file 'user-config.jam' from '/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build'.
notice: [zlib] Using pre-installed library
notice: [zlib] Condition
notice: [bzip2] Using pre-installed library
notice: [bzip2] Condition
warning: toolset clang-linux initialization: can not find tool clang++
warning: initialized from /home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/user-config.jam:5
sh: 1: clang++: not found
notice: will use 'clang++' for clang-linux, condition <toolset>clang-linux
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/tools/clang-linux.jam:69: in clang-linux.init
*** argument error
* rule clang.init-cxxstd-flags ( toolset : condition * : version )
* called with: ( clang-linux : <toolset>clang-linux : )
* missing argument version
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/tools/clang.jam:54:see definition of rule 'clang.init-cxxstd-flags' being called
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build/toolset.jam:44: in toolset.using
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build/project.jam:1104: in using
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/user-config.jam:5: in modules.load
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build-system.jam:255: in load-config
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build-system.jam:449: in load-configuration-files
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/build-system.jam:607: in load
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/kernel/modules.jam:295: in import
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/src/kernel/bootstrap.jam:139: in boost-build
/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/boost-build.jam:17: in module scope
boost/1.76.0:
boost/1.76.0: ERROR: Package '1e5ed3b96aff577e610fddd01bd296a709542e8c' build failed
boost/1.76.0: WARN: Build folder /home/local/.conan/data/boost/1.76.0/_/_/build/1e5ed3b96aff577e610fddd01bd296a709542e8c
ERROR: boost/1.76.0: Error in build() method, line 807
self.run(full_command, run_environment=True)
ConanException: Error 1 while executing b2 -q numa=on target-os=android architecture=arm address-model=64 binary-format=elf abi=aapcs --layout=system --user-config=/home/local/.conan/data/boost/1.76.0/_/_/source/source_subfolder/tools/build/user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=on boost.locale.iconv.lib=libc threading=multi visibility=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave toolset=clang-linux pch=on cxxflags="-fPIC -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/home/local/.conan/data/boost/1.76.0/_/_/package/1e5ed3b96aff577e610fddd01bd296a709542e8c -j12 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/local/.conan/data/boost/1.76.0/_/_/build/1e5ed3b96aff577e610fddd01bd296a709542e8c"

Related

Problems attempting to build oboe c++ library using cmake on windows

I am attempting to build 'oboe' on a windows machine using cmake (version 3.25.0) and a visual studio generator. The end goal is to create a c++ audio library that uses oboe as the back end for android, but as a first step simply geting oboe to build is the plan.
I have managed to succesfully generate build and use a static library with a few simple test functions using the method described below, but I run into errors when attempting to build oboe.
I have also managed to get oboe to build by using the method described in the documentation and
doing add_subdirectory etc. in the CMakeLists file of android studio. However I am trying to generate/ build using cmake outside of android studio.
The oboe repo is found here: https://github.com/google/oboe
The toolchain file I am using is: 'android.toolchain.cmake' included in the NDK at the location: ndk version/build/cmake/android.toolchain.cmake
I use a batch script to automate generating/ building to several different android ABI's, inspired by a similar shell script included with the oboe repo 'build_all_android.sh'. The .bat script I made is shown below:
#echo OFF
set BUILD_DIR=build
set ANDROID_NDK=C:\Microsoft\AndroidNDK\android-ndk-r23c
set GENERATOR="Visual Studio 17 2022"
set CMAKE_GENERATOR=-G %GENERATOR%
set CMAKE_TOOLCHAIN_FILE=-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake
set CMAKE_SYSTEM_NAME=-DCMAKE_SYSTEM_NAME=Android
set EXTRA_CMAKE_ARGS=-DBUILD_SHARED_LIBS=true -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static
CALL :build_android armeabi-v7a ARM 16
CALL :build_android arm64-v8a ARM64 21
CALL :build_android x86_64 x64 21
CALL :build_android x86 x86 16
EXIT /B %ERRORLEVEL%
:build_android
set ABI_VERSION=%~1
set GENERATOR_PLATFORM=%~2
set MINIMUM_API_LEVEL=%~3
set CMAKE_ANDROID_ARCH_ABI=-DANDROID_ABI=%ABI_VERSION%
set ABI_BUILD_DIR=%BUILD_DIR%\%ABI_VERSION%
set CMAKE_GENERATOR_PLATFORM=-A %GENERATOR_PLATFORM%
set CMAKE_BUILD_DIR=-B %ABI_BUILD_DIR%
set CMAKE_MIN_API=-DANDROID_PLATFORM=android-%MINIMUM_API_LEVEL%
set CMAKE_ARGS=%CMAKE_BUILD_DIR% %CMAKE_ANDROID_ARCH_ABI% %CMAKE_GENERATOR% %CMAKE_GENERATOR_PLATFORM% %CMAKE_SYSTEM_NAME% %CMAKE_TOOLCHAIN_FILE% %CMAKE_MIN_API%
echo building for android ABI: %ABI_VERSION%
echo cmake arguments = %CMAKE_ARGS%
echo:
cmake %CMAKE_ARGS% %EXTRA_CMAKE_ARGS%
echo:
cmake --build %ABI_BUILD_DIR% --target ALL_BUILD
echo:
echo:
EXIT /B 0
When I run this using the ANDROID_NDK variable (line 3) pointing to the root of the up to date ndk that comes with the visual studio 2022 android tools, I get an error:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Microsoft/AndroidNDK/android-ndk-r23c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: C:/Microsoft/AndroidNDK/android-ndk-r23c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
The C compiler
"C:/Microsoft/AndroidNDK/android-ndk-r23c/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/user/Documents/Code Projects/oboe/build/x86/CMakeFiles/CMakeScratch/TryCompile-pp2ibg
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_c21fb.vcxproj /p:Configuration=Debug /p:Platform=x86 /p:VisualStudioVersion=17.0 /v:m && MSBuild version 17.4.1+9a89d02ff for .NET Framework
ANDROID_HOME=C:\\Microsoft\AndroidSDK\25
ANDROID_SDK_ROOT=C:\\Microsoft\AndroidSDK\25
ANT_HOME=
JAVA_HOME=C:\Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08
NDK_ROOT=C:\Microsoft\AndroidNDK\android-ndk-r23c
testCCompiler.c
In file included from <built-in>:349:
<command line>(1,9): warning : '__ANDROID_API__' macro redefined [-Wmacro-redefined] [C:\Users\user\Documents\Code Projects\oboe\build\x86\CMakeFiles\CMakeScratch\TryCompile-pp2ibg\cmTC_c21fb.vcxproj]
#define __ANDROID_API__ 1
^
<built-in>(342,9): note: previous definition is here
#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
^
1 warning generated.
ld: error: cannot open crtbegin_so.o: No such file or directory
ld: error: unable to find library -llog
ld: error: unable to find library -landroid
ld: error: cannot open crtend_so.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Application Type\Android\3.0\Android.Common.targets(125,5): error MSB6006: "clang.exe" exited with code 1. [C:\Users\user\Documents\Code Projects\oboe\build\x86\CMakeFiles\CMakeScratch\TryCompile-pp2ibg\cmTC_c21fb.vcxproj]
CMake will not be able to correctly generate this project.
and cmake fails to generate the project. I can actually get this to generate correctly, but only if I set the android NDK version within the cross-compilation options of visual studio to use the NDK bundled with my installation of Android studio, and also set the ANDROID_NDK variable of the batch script to point to the same root.
In this case, though cmake generates the project the build fails with a similar reason to the warning given above:
Building Custom Rule C:/Users/user/Documents/Code Projects/oboe/CMakeLists.txt
AAudioLoader.cpp
In file included from <built-in>:404:
<command line>(1,9): error : '__ANDROID_API__' macro redefined [-Werror,-Wmacro-redefined] [C:\Users\user\Documents\Co
de Projects\oboe\build\x86\oboe.vcxproj]
#define __ANDROID_API__ 16
^
<built-in>(394,9): note: previous definition is here
#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
^
1 error generated.
Thanks in advance for any help, it is much appreciated!
Your build fails because you instruct the compiler to view the warning '__ANDROID_API__' macro redefined as an error. And this warning seems to occur because Visual Studio still sets the macro __ANDROID_API__ instead of setting __ANDROID_MIN_SDK_VERSION__. I think that is a Visual Studio bug that was introduced when they started shipping the NDK 23 instead of 21.
EDIT:
This issue is being tracked here.

Error: use of undeclared identifier 'PTHREAD_MUTEX_ROBUST' cargo build liblmdb-sys for aarch64-linux-android target

I am trying to compile a rust project into an Android target (aarch64-linux-android).
From the comments in the lmdb code, it seems to need to run the compilation
"aarch64-linux-android-gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-o" "/Users/username/grin-wallet/target/aarch64-linux-android/release/build/liblmdb-sys-7a2d430dc3c9f3e3/out/mdb/libraries/liblmdb/mdb.o" "-c" "mdb/libraries/liblmdb/mdb.c"
with an additional -DMDB_USE_ROBUST=0 flag. Is this configurable from either the cargo build command or adding something to Cargo.toml?
The error I am getting is:
error: failed to run custom build command for `liblmdb-sys v0.2.2`
Caused by:
process didn't exit successfully: `/Users/username/grin-wallet/target/release/build/liblmdb-sys-b6bfc7b665736f9b/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("aarch64-linux-android")
TARGET = Some("aarch64-linux-android")
HOST = Some("x86_64-apple-darwin")
TARGET = Some("aarch64-linux-android")
TARGET = Some("aarch64-linux-android")
HOST = Some("x86_64-apple-darwin")
CC_aarch64-linux-android = None
CC_aarch64_linux_android = None
TARGET_CC = None
CC = None
TARGET = Some("aarch64-linux-android")
HOST = Some("x86_64-apple-darwin")
CFLAGS_aarch64-linux-android = None
CFLAGS_aarch64_linux_android = None
TARGET_CFLAGS = None
CFLAGS = None
DEBUG = Some("false")
running: "aarch64-linux-android-gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-Wall" "-Wextra" "-o" "/Users/username/grin-wallet/target/aarch64-linux-android/release/build/liblmdb-sys-7a2d430dc3c9f3e3/out/mdb/libraries/liblmdb/mdb.o" "-c" "mdb/libraries/liblmdb/mdb.c"
cargo:warning=mdb/libraries/liblmdb/mdb.c:4625:13: warning: implicit declaration of function 'pthread_mutexattr_setrobust' is invalid in C99 [-Wimplicit-function-declaration]
cargo:warning= || (rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST))
cargo:warning= ^
cargo:warning=mdb/libraries/liblmdb/mdb.c:4625:49: error: use of undeclared identifier 'PTHREAD_MUTEX_ROBUST'
cargo:warning= || (rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST))
cargo:warning= ^
cargo:warning=mdb/libraries/liblmdb/mdb.c:9821:33: warning: unused parameter 'env' [-Wunused-parameter]
cargo:warning=mdb_env_get_maxkeysize(MDB_env *env)
cargo:warning= ^
cargo:warning=mdb/libraries/liblmdb/mdb.c:10002:10: warning: implicit declaration of function 'pthread_mutex_consistent' is invalid in C99 [-Wimplicit-function-declaration]
cargo:warning= rc2 = mdb_mutex_consistent(mutex);
cargo:warning= ^
cargo:warning=mdb/libraries/liblmdb/mdb.c:351:37: note: expanded from macro 'mdb_mutex_consistent'
cargo:warning=#define mdb_mutex_consistent(mutex) pthread_mutex_consistent(mutex)
cargo:warning= ^
cargo:warning=3 warnings and 1 error generated.
exit code: 1
First, make sure you have all the android build targets installed:
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android
Then install cargo-ndk
cargo install cargo-ndk
Now you need to export a number of variables in the terminal that will be used by the build.
If you are using pkg-config then
export PKG_CONFIG_ALLOW_CROSS=1
The root directory of the NDK
export NDK_HOME=the_path_to_the_ndk
The platform version
export NDK_API_LEVEL=the_api_level
Note that the compilers must be specified as clang for newer versions of the NDK since GCC was deprecated in the android toolchain and is no longer present (some projects try to reference GCC by default)
export CC=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android$NDK_API_LEVEL-clang
export CXX=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android$NDK_API_LEVEL-clang++
Then the rest of the variables
export AR=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar
export AS=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-as
export LD=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ld
export RANLIB=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ranlib
export STRIP=$NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-strip
You were on the right track in thinking -DMDB_USE_ROBUST=0, it just needed to be passed to the compiler flags
export CFLAGS=-DMDB_USE_ROBUST=0
Then in your rust project, you will need to create a .config directory in the same directory as your .toml file. Within the .config directory, you will need to create a config file.
In the config file you will need to specify the relevant build targets for each target you need built (replace NDK_HOME and NDK_API_LEVEL with their respective values)
[target.aarch64-linux-android]
ar = "<NDK_HOME>/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar"
linker = "<NDK_HOME>/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android<NDK_API_LEVEL>-clang"
You should then be able to build successfully with
cargo ndk --target aarch64-linux-android --android-platform $NDK_API_LEVEL -- build --release
You can't just build and targeting to linex-android, another way to do this is develop your app via Android Studio or with Flutter

How get fast pixel color on Android use ScreenshotClient?

I want get color pixel use an binary file with params x and y. The screencap is very slow. Using a virtual display also does not give the desired result.
I found and code screencap, and good project: sji-android-screen-capture-old and sji-android-screen-capture-new.
But those solutions don't run in my phone. If run get-raw-image.cpp after compile get-raw-image.cpp I get errors:
WARNING: linker: /data/local/tmp/get-raw-image-4.1.2: unused DT entry: type 0xf arg 0x21d
CANNOT LINK EXECUTABLE: cannot locate symbol "_ZN7android16ScreenshotClient6updateERKNS_2spINS_7IBinderEEE".
For compilation, I use the following settings:
/root/arm/bin/arm-linux-androideabi-clang -pie get-raw-image.cpp -lsupc++ libgui.so -o /get-raw-image-4.1.2 -Xlinker -rpath=/system/lib -DTARGET_JB
If run Android-fast-screen-capture:
/root/arm/bin/arm-linux-androideabi-clang -pie /screen/ascreencap.cpp -o /test -std=c++11
I had errors:
In file included from /screen/ascreencap.cpp:8:
In file included from /root/arm/bin/../sysroot/usr/include/binder/IPCThreadState.h:21:
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:86:11: error: unknown type
name 'binder_size_t'
const binder_size_t* objects() const;
^
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:220:47: error: unknown type
name 'binder_size_t'
const binder_size_t* objects, si...
^
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:228:51: error: unknown type
name 'binder_size_t'
const binder_size_t* objects...
^
/root/arm/bin/../sysroot/usr/include/binder/Parcel.h:264:5: error: unknown type
name 'binder_size_t'
binder_size_t* mObjects;
^
In file included from /screen/ascreencap.cpp:8:
/root/arm/bin/../sysroot/usr/include/binder/IPCThreadState.h:114:50: error:
unknown type name 'binder_size_t'
const binder_size_t* objects...
^
5 errors generated.
Also I found the question how-to-use-screenshotclient-in-my-android-application but I don't understand how set link to ScreenshotClient, so that the compiler does not return an error.
My phone is Homtom HT16:
Processor : ARMv7 Processor rev 3 (v7l)
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 26.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
Maybe someone will tell you how to compile the code under my phone or which way to go to solve the problem.
I solved my problem.
Steps:
1) Copy need library from android phone (libgui.so, libui.so, libcutils.so, libutils.so, libbinder.so).
2) Add in sys_root (when save ndk lib code files from Android Android 6_r1 libs: utils, cutils, system, log, hardware, system, ports, core, include/gui, include/ui, include/binder). You can run this code for find your system root:
echo "#include <bogus.h> int main(){}" > t.c; GCC_OR_CLANG_BINARY_LINK -v t.c; rm t.c
Erors printed all paths where compiler search include files.
or use --sysroot=YOUR_PATH for set your path.
3) Add flags -Wl,--unresolved-symbols=ignore-all for ignore errors and --target=armv7-none-linux-androideabi23 (23 or other) for set target version.
Full my clang command:
/Users/macbookair/Documents/test/bin/clang -fPIE -pie fast-screen-capture.cpp *.so -o ./screencap --target=armv7-none-linux-androideabi23 -Wl,--unresolved-symbols=ignore-all -s
Successes!

NDK build error: "fatal error: stdint.h: No such file or directory" on Mac Os X

I use the following build command to build OpenH264 project.
make OS=android ARCH=arm64 NDKROOT=~/Library/Android/android-ndk-r10d/ TARGET=android-12
But i got the following error:
/Users/jerikc/Library/Android/android-ndk-r10d/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9/include-fixed/limits.h:168:61: error: no include path in which to search for limits.h
#include_next <limits.h> /* recurse down to the real one */
^
In file included from ./codec/common/inc/typedefs.h:48:0,
from ./codec/common/inc/wels_common_defs.h:37,
from codec/common/src/common_tables.cpp:33:
/Users/jerikc/Library/Android/android-ndk-r10d/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/lib/gcc/aarch64-linux-android/4.9/include/stdint.h:9:26: fatal error: stdint.h: No such file or directory
# include_next <stdint.h>
^
compilation terminated.
You request target platform 12, which does not support arm64. The lowest TARGET for this architecture is android-21.
There is probably some glitch in the script, and we must set the platform twice in the build command:
make OS=android ARCH=arm64 TARGET=android-21 NDKLEVEL=21
Make sure that NDKROOT and PATH are set correctly.

compile and build “iw” for android 4.1 device?

i need to install iw wireless packages on android 4.1 device. but i don't know how and what is the require version of the packages to install !!
also is it need linux platform to do this or it is enough to build and install on adb shell for android rooting device.
i see this link but when i do it from adb terminal i see that git and some shells not found ??? how to do it ?
it seems no one has any idea ??
While building iw version 3.11 (which has an Android.mk file already), I encountered some issues due to missing/ wrong headers and libraries. Since it has an Android.mk file, the NDK can be used.
In the following I will assume the following:
A device image has been built before (the kernel headers and libnl-2 static library should at least be available). I have built CyanogenMod 10 (with kernel 3.0.something) for the i9300, update the paths below to reflect that.
The NDK is installed to ~/android/system/ndk.
The NDK has appropriate platforms and toolchains installed.
Preparation after extracting iw-3.11.tar.xz and changing my directory in it:
ln -s . jni
ln -nsv ~/android/system/external ./
The next issue is the netlink library:
In file included from external/libnl-headers/netlink/genl/genl.h:15:0,
from /tmp/and/iw/jni/iw.c:17:
external/libnl-headers/netlink/netlink.h:27:29: fatal error: linux/genetlink.h: No such file or directory.
Simply creating a link to the android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux breaks other headers badly which will give errors such as:
Compile thumb : iw <= iw.c
In file included from /home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/net/if.h:28:0,
from /tmp/and/iw/jni/iw.c:10:
/tmp/and/iw/jni/linux/if.h:178:19: error: field 'ifru_addr' has incomplete type
/tmp/and/iw/jni/linux/if.h:179:19: error: field 'ifru_dstaddr' has incomplete type
/tmp/and/iw/jni/linux/if.h:180:19: error: field 'ifru_broadaddr' has incomplete type
/tmp/and/iw/jni/linux/if.h:181:19: error: field 'ifru_netmask' has incomplete type
/tmp/and/iw/jni/linux/if.h:182:20: error: field 'ifru_hwaddr' has incomplete type
In file included from external/libnl-headers/netlink/netlink.h:20:0,
from external/libnl-headers/netlink/genl/genl.h:15,
from /tmp/and/iw/jni/iw.c:17:
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:74:44: warning: 'struct msghdr' declared inside parameter list [enabled by default]
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:74:44: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
/home/user/android/system/ndk/platforms/android-14/arch-arm/usr/include/sys/socket.h:75:38: warning: 'struct msghdr' declared inside parameter list [enabled by default]
In file included from external/libnl-headers/netlink/netlink.h:25:0,
from external/libnl-headers/netlink/genl/genl.h:15,
from /tmp/and/iw/jni/iw.c:17:
/tmp/and/iw/jni/linux/netlink.h:33:2: error: unknown type name 'sa_family_t'
In file included from external/libnl-headers/netlink/genl/genl.h:15:0,
from /tmp/and/iw/jni/iw.c:17:
external/libnl-headers/netlink/netlink.h:51:16: warning: 'struct msghdr' declared inside parameter list [enabled by default]
external/libnl-headers/netlink/netlink.h:54:19: warning: 'struct iovec' declared inside parameter list [enabled by default]
make: *** [/tmp/and/iw/obj/local/armeabi/objs/iw/iw.o] Error 1
A workaround is to create the linux directory and put a symlink to ~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h in it:
mkdir -p linux
ln -svn ~/android/system/out/target/product/i9300/obj/KERNEL_OBJ/usr/include/linux/genetlink.h linux/
Finally patch Android.mk to finish linking to the netlink library:
sed "/LOCAL_LDFLAGS/s#\$# -L$HOME/android/system/out/target/product/i9300/obj/STATIC_LIBRARIES/libnl_2_intermediates -lnl_2#" -i Android.mk
Now the build can be started:
NDK_PROJECT_PATH=$PWD ~/android/system/ndk/ndk-build TARGET_PLATFORM=android-14
It will not complete because netlink/genl/genl.h cannot be found, but the iw
binary is available in libs/armeabi!

Categories

Resources