Android build is failing when trying to build with ndk16 - arm64

I am trying to build arm64 apk with ndk16 using ruby. Why is it failing. It seems to be some jni issue.
I am using gcc compiler toolchain to build the apk
It should build arm64 apk with gcc toolchain.

GCC is not supported in ARM64 and try using CLANG compiler with NDK19 and above.

Related

Cannot cross-compile static C library for iPhone (arm64) on macOS (x86_64)

I've been trying to cross-compile a static C library for use in an iOS application.
I figured that this can be achieved by wrapping the headers and binaries in an XCFramework, but the compiled library is for an x86_64 architecture, so it can't run on iOS.
What I did was the following:
export IOS_SDK_LOC=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
export AARCH64_FLAGS="-arch arm64 -isysroot $IOS_SDK_LOC "
./configure --host=arm_apple_darwin --build=x86_64_apple_darwin --target=x86_64_apple_darwin
\ CFLAGS=$AARCH64_FLAGS CPPFLAGS=$AARCH64_FLAGS
I initially tried to just have the CFLAGS, but ended up passing the same arguments as CPPFLAGS as well following the answer at Can't cross compile C library for arm (iOS)
In either case, I get the same error:
configure: error: cannot run test program while cross compiling
How should I go about compiling my library in this case?
The workaround I found for compiling an arm64 static library on the same machine was to install QEMU (machine emulator), with the target OS in mind.
As luck would have it, Jonathan Afek from Aleph Security recently wrote a frame buffer for iOS QEMU, making it particularly easy to work with now.
More information here: https://www.reddit.com/r/jailbreak/comments/kxr0v8/news_ios_qemu_is_getting_a_graphical_display_ios/

How to enable Bitcode for WebRTC iOS framework?

How can I compile WebRTC iOS framework with Bitcode enabled. Currently I have to disable the Bitcode of my project due to WebRTC framework.
You will need to build it yourself.
Something like:
# Clone the depot tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# Add the tools to the path
export PATH=$PATH:"`pwd`/depot_tools"
# Download the WebRTC source code
mkdir webrtc_ios
cd webrtc_ios
# This will take some time
fetch --nohooks webrtc_ios
gclient sync
# Let's start building
cd src
# Build the framework, remove --arch "arm64 x64" to build ALL architectures, including 32 bit
tools_webrtc/ios/build_ios_libs.py --bitcode --arch arm64 x64
# The framework is at out_ios_libs/WebRTC.framework
Documentation: https://webrtc.github.io/webrtc-org/native-code/ios/
Update:
Starting with Xcode 14, bitcode is no longer required (see release notes), and no longer supported in submissions.
The google WebRTC neglected to fix an ARM build issue with bitcode for so long, they just waited it out...
the --bitcode option is no longer supported by the build script.
To continue building using my instructions, remove it:
tools_webrtc/ios/build_ios_libs.py --arch arm64 x64
according to the official doc, you have to compile manually. More details there:
main page: https://webrtc.org/native-code/development/
iOS page: https://webrtc.org/native-code/ios/
bottom of the page (last paragraph) includes instructions to build with bitcode support:
To build the framework with bitcode support, pass the --bitcode flag to the script like so
python build_ios_libs.py --bitcode

Ios - Wrong architecture building WebRTC

I'm building WebRTC for iOS. To do that, I'm using the following bash script:
# Set flags to compile in arm64
export GYP_GENERATORS="ninja"
export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=1 libjingle_objc=1 OS=ios target_arch=arm64"
export GYP_GENERATOR_FLAGS="output_dir=out_ios_arm64"
export GYP_CROSSCOMPILE=1
# Generate metadata for compile
gclient runhooks
# Compile webRTC in Release and verbose mode
ninja -v -C src/out_ios_arm64/Release-iphoneos AppRTCDemo
In the same machine and the same dir, I have compiled for armv7 and now when I try to build with the code above, the library is compiled for armv7. Maybe I have some metadata info in my dir that I'm not removing or something but I understand that if I set target_arch=arm64 in my GYP_DEFINES I should see my library compiled for this arch. Any idea what could be happening?
P.D: I need to build for both (armv7 and arm64) in order to generate with lipo an universal lib.

Compile IOS program from linux commandline

I want to compile my IOS appication from linux terminal(command line)....
Is it possible to do so, if yes, then how?
Yes, it's possible.
At least you need:
Assembler and Linker: cctools and ld64 from apple opensource.
Compiler: Clang/LLVM
SDK, include headers and libraries.
Utilities: such as ldid codesign tool.
Step 1 : The compiler
Clang/llvm >= 3.2 is highly recommended and tested.
If you want to build clang/llvm from scratch, Please refer to this link to build a svn version for your linux distribution.
If your distribution already provides clang/llvm packages,make sure it is 3.2 release or above. Lower version may work but isn't tested.
for Ubuntu 13.04 and later, clang/llvm already provided in repos, please run:
$sudo apt-get install gcc g++ clang libclang-dev uuid-dev libssl-dev libpng12-dev libicu-dev bison flex libsqlite3-dev
to install some dev packages, other dev packages related to llvm/llvm-dev should be installed automatically.
Step 2 : The assembler and linker
The latest cctools-855 and ld64-236.3 had been ported from Apple opensource to linux. the porting process is a little bit complicated, also with a lot of codes modified for linux, let's just skip it.
please check out the codes from:
svn checkout http://ios-toolchain-based-on-clang-for-linux.googlecode.com/svn/trunk/cctools-porting
Build it:
$ sed -i 's/proz -k=20 --no-curses/wget/g' cctools-ld64.sh
$ ./cctools-ld64.sh
$ cd cctools-855-ld64-236.3
$
$ ./configure --target=arm-apple-darwin11 --prefix=/usr
$ make
$ make install
For Ubuntu 13.04, since the clang/llvm 3.2 package use a customized libraries/headers path. please setup CFLAGS and CXXFLAGS first before run configure.
$export CFLAGS="-I/usr/include/llvm-c-3.2"
$export CXXFLAGS="-I/usr/include/llvm-c-3.2"
Step 3: The iPhoneOS SDK.
The old iPhone SDK with ARC support extracted from xcode had been provided in Download Sections. You can directly download it and extract it to /usr/share
For iOS 4.2: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS4.2.sdk.tar.xz
For iOS 5.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS5.0.sdk.tar.xz
For iOS 6.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS6.0.sdk.tar.xz
For other iOS versions, You may need follow these steps to get the SDK for your self.
Step 4: The utilities
iphonesdk-utils is a utility collection for iOS development, provides below utilities:
NOTE: (Some of them are collected from internet with some modifications.)
ldid : codesign tool, with armv7/armv7s support and other changes from orig version. it will be involked by ld64 after link complete.
ios-clang-wrapper : automatically find SDK and construct proper compilation args.
ios-switchsdk : switch sdk when multiple version of SDK exist.
ios-pngcrush: png crush/de-crush tool, like Apple's pngcrush.
ios-createProject : project templates
ios-genLocalization : iOS app localization tool based on clang lexer.
ios-plutil : plist compiler/decompiler.
ios-xcbuild : convert xcode project to makefile, build xcode project directly under linux.
Download the source tarball from: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz
Build and install it:
$./configure --prefix=/usr
$make
$make install
Build App
Now you can build and install your project simply doing:
$cd ProjectDir
$make
$make install IPHONE_IP=<your own device IP
Complete info you can find here — https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/wiki/HowTo_en
The above solution given by Barjomet is correct incase if its not mavericks, but if it is Maverics then following is the solution:
1) Install the appropriate command line tool
2) for building :a)xcodebuild -list -project .xcodeproj
b)- xcodebuild -scheme build
For detail reference you can refer the following link:
https://developer.apple.com/library/ios/technotes/tn2339/_index.html.

Building a c based static library for iOS

I need a network library for my c library so I can use it on both iOS and android. I've been searching around and tried to build libcurl as a static library but wasn't successful.
I built it with the following settings
$ export CC="clang"
$ export CFLAGS="-Wall -g -std=c11 -pipe -Os -gdwarf-2"
$ ./configure --enable-static
make install
It runs fine when I test the library with my test.c library. However, when I run it on my iOS project, I got a mismatch on CurlchkszEQ(long, CURL_SIZEOF_LONG)
I think the problem was that CURL_SIZEOF_LONG is set to be 8 while long in iOS is 4.
Does anyone know what went wrong with my config setting?
You want to cross-compile libcurl for iOS but the problem here is that you use clang which by default produces 64-bit x86_64 object files.
In other words you need to work with the iOS toolchain (xcrun -sdk iphoneos clang), provide the right architecture flag(s)[1] (e.g -arch armv7) and use the right sysroot path.
I recommend you to refer to:
curl-ios-build-scripts: a collection of handy scripts used to build (lib)curl for iOS 5+ and OSX 10.7+,
or, http://seiryu.home.comcast.net/~seiryu/libcurl-ios.html which provides a ready-to-use a precompiled binary.
[1]: you may want to produce a fat library that targets ARMv7, ARMv7s and i386 (simulator) architectures.

Resources