Unable to cross compile iOS programs on linux - ios

I know that someone already asked this question but it isn`t up to date anymore. Most of the links are dead and the commands are not relevant anymore.
I have read these
Compile IOS program from linux commandline
How to cross-compile clang/llvm for iOS?
For example, I have been trying to compile silversearcher-ag for my iPhone 6 (jailbroken). This is the project link https://github.com/ggreer/the_silver_searcher.
I am targeting iOS 12.4.
These are the commands that I`ve tried
./configure CC=/home/growtopiajaw/Desktop/cctools-port-master/usage_examples/ios_toolchain/target/bin/arm-apple-darwin11-clang CXX=/home/growtopiajaw/Desktop/cctools-port-master/usage_examples/ios_toolchain/target/bin/arm-apple-darwin11-clang++ --host=arm-apple-darwin11
make
I am using cctools-port to cross compile the project. My compiled cctools toolchain is located under /home/growtopiajaw/Desktop/cctools-port-master/usage_examples/ios_toolchain/target and below is how the toolchain`s directory structure looks like
This is my configure log: https://del.dog/nugibonury
This is my make log:
CC src/ignore.o
In file included from src/ignore.c:11:
./src/options.h:7:10: fatal error: 'pcre.h' file not found
#include <pcre.h>
^~~~~~~~
1 error generated.
make: *** [Makefile:494: src/ignore.o] Error 1
This is my GitHub repository containing the cross compile toolchain
https://github.com/GrowtopiaJaw/arm-apple-darwin11

Apple does not ship PCRE. You need to get the headers and dylib/tbd files manually.
If you're using checkra1n or unc0ver, then the deb on the APT repo contains headers as well, so you could just use that.
If you plan to package this into an APT/dpkg file, make sure to add pcre as a dependency.

Related

Using ZMQ on iOS

I am trying to build an iOS app that is exposed to a fairly extensive Rust project, but I am having issues with one of the dependencies in the project. The Rust project has a ZMQ dependency, and while I am able to build the project on my Mac, when I try to incorporate the Rust project I get the following error:
error: failed to run custom build command for `zmq-sys v0.8.3`
Caused by:
process didn't exit successfully: `/Users/lisa/company/project/project_detail/target/debug/build/zmq-sys-16dfc88dff84d855/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBZMQ_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64-apple-ios
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_aarch64_apple_ios
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
thread 'main' panicked at 'Unable to locate libzmq:
pkg-config has not been configured to support cross-compilation.
Install a sysroot for the target platform and configure it via
PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
cross-compiling wrapper for pkg-config and set it via
PKG_CONFIG environment variable.', /Users/lisa/.cargo/registry/src/github.com-1ecc6299db9ec823/zmq-sys-0.8.3/build.rs:31:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
I am trying to build the appropriate library for the iOS and iOS simulator architectures without relying on pkg-config, but if someone can provide useful instructions for configuring pkg-config for cross-compilation, I am not opposed to it, I just don't know how and can't find any up to date resources.
I have cloned the libzmq project from this github: https://github.com/zeromq/libzmq.git, then navigate into libzmq.
Inside libzmq, I run ./autogen.sh followed by ./configure --prefix [directory location] --target "aarch64-apple-ios", then make and make install.
The above procedure without the --target flag is how I got the project to compile on my Mac in the first place, and with the target flag in place make and make install both complete successfully, but when I try to build the project using PROJECT_DIR="${PWD}/ProjectName" ./ProjectName/build-rust.sh,
I get the previously posted error.
I am following the Swift-Bridge Book (https://chinedufn.github.io/swift-bridge/building/xcode-and-cargo/index.html) to try to load the Rust libraries into Xcode.
One thing to note: In the libzmq git hub, there is a folder called builds/ios/ and inside this folder is what looks to be a build file for all of the iOS archs, but I haven't been able to get the repo to build with that file. I think figuring out how to use the build_ios.sh build file as opposed to the standard build.sh provided might be the answer, but I've tried dropping build_ios.sh where build.sh is, and ./autogen.sh doesn't work, because it complains that it can't find configure.ac, even though this file does exist.

Lambdanative can compile for OSX but not iOS

I'm running Sierra with XCode 8.3 including command line tools. I can use Gambit to compile to OSX native code. I can use lambdanative to compile the test Calculator app to OSX but when I try to configure and then compile for iOS I get the following error in verbose mode:
checking whether the C compiler works... no
configure: error: in `/Users/querist/.lambdanative/tmp_install/gambc-v4_7_9':
configure: error: C compiler cannot create executables
See `config.log' for more details
ERROR: failed with exit code 77
There is no config.log to read. I've done a search for it and there is not one related to this project.
Any ideas? I really like the idea of being able to develop iOS apps in Scheme.
Thanks.
I realize this may be too late, but in case somebody else stumbles upon this, I though I'd try to explain.
config.log is placed in the library output directory, not your working folder. You can look for it by running find ~/Library/ -name 'config.log'.
In my case, config.log revealed the problem is that it can't find some version of a crt library. This problem is addressed here.
I edited my ./SETUP file from my lamdbanative working directory folder, so that IOSVERSION went from the 5.1.1 default to 6.0. That solved the problem for me.

how to build DLIB for iOS

I'm trying to build DLIB for an iOS project. Running the cmake results in a libdlib.a and a load of .o files.
When I add the library to an Xcode project I get warning that the library hasn't been built for arm64.
My question is two-part:
How can I build DLIB for iOS (I tried cmake **path_to_source** -DCMAKE_OSX_ARCHITECTURE="arm64" but it caused loads of errors e.g. unknown type name '__uint32_t'; did you mean '__uint128_t')?
What is the purpose of all the .o files that get built when you run cmake? Do I need to include them in an Xcode project?
I finally figured out how to do this:
Requirements
X11 (on a mac you can just open the X11 app and if X11 isn't installed it'll take you to the download).
Xcode
cmake (you can use home-brew for that)
Steps
In terminal make the lib-xx.xx/examples your root
Run:
mkdir build
cd build
cmake -G Xcode ..
cmake --build . --config Release
This will create a folder called dlib_build in which you can find an Xcode project that compiles the library. In the build settings of that Xcode project you can set the build architecture and SDK for any Xcode supported OS you like!
EDIT:
You have to include a lot of custom compiler flags and 3rd party libraries to get dlib to work in a project. Check out the examples.xcproject build settings.
To compliment RASS's answer, I am attaching screenshots showing how to change this to and from an iOS and OSX lib
After opening the project,
Select the project file from the project navigator
Select the dlib target all the way down the bottom
Select 'Build Settings'
Expand 'Base SDK' drop down
Select either iOS or macOS (OSX)
I hope this helps some people out! gl
Rob Sanders and mylogon already show how to build dlib for ios, here is how to use it:
add libdlib.a to project, and add path to library search paths
add all source to include directory(do not add to project), and add path to header search paths.
add accelerate framework, which contains blas symbols.
add preprocessor macros, from building settings, "custom compiler flag"/"other c flags". these macros make sure the header files match the lib.
-DDLIB_JPEG_SUPPORT
-DDLIB_NO_GUI_SUPPORT
-DNDEBUG
-DDLIB_USE_BLAS
-DDLIB_USE_LAPACK

library not found for lcrypto

I'm trying to build the iOS AllJoyn project, but I'm having trouble with the OpenSSL integration.
I've been looking at these directions: https://allseenalliance.org/docs-and-downloads/documentation/configuring-build-environment-ios-and-osx#unique_16
I've followed the directions all the way up to Xcode IDE Build, but now I'm getting an error that says: "library not found for lcrypto".
Looking online it looks like there might be something to do with the Makefile, but I'm not really sure what lcrypto is and what library I'm supposed to be referencing.
EDIT
I noticed that it says it is a Shell Script Invocation Error
Also here is the trace:
ld: warning: directory not found for option '-L/PATH/alljoyn/alljoyn/common/crypto/openssl/build/Debug-iphoneos'
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [build/darwin/arm/iphoneos/debug/obj/test/bbcclient] Error 1
scons: building terminated because of errors.
Command /usr/local/bin/scons failed with exit code 2
In order to successfully use the AllJoyn SDK you need to have a compiled version of the openssl library available (i.e. libcrypto.a).
The details to build the openssl library can be found in the README-INSTALLING.txt file under /alljoyn_objc in the SDK, I have copied the relevant instructions below. Once you have created the openssl library you need to place it in a directory accessible to your project (in your case "/PATH/alljoyn/alljoyn/common/crypto/openssl/build/Debug-iphoneos").
Most of this information is contained in the AllJoyn Programming Guide for Objective-C
Relevant text from the README-INSTALLING.txt file:
OpenSSL is required for iOS development and is available at the following web
address: www.openssl.org
AllJoyn has been tested with version 1.0.1 of OpenSSL.
Download the Xcode project that can be used to build OpenSSL for iOS from GitHub,
at the following web address: https://github.com/sqlcipher/openssl-xcode/
Installation
Copy the OpenSSL source into a separate folder on your development system, not
under the AllJoyn SDK.
Navigate to the OpenSSL source top folder in Finder, and copy the openssl.xcodeproj
folder you downloaded from GitHub into this folder.
Open the openssl.xcodeproj in Xcode.
In Xcode, build the crypto target (libssl.a and libcrypto.a) for each
combination of configuration (debug|release) and platform (iphoneos|iphonesimulator) that you
need for your iOS project by selecting Product->Build For->(your desired configuration).

DCMTK question error: libc.h: No such file or directory

I am trying to write simple dcmtk application I adeed the following header
#include <dcmtk/config/osconfig.h>
#include <dcmtk/dcmimgle/dcmimage.h>
it give the error error: libc.h: No such file or directory
I use xcode and mac os snow leopard
any suggestin please
I assume you're trying to compile for iOS? When you setup DCMTK to generate the appropriate build files, add this line to CMakeLists.txt before you run CMake:
SET(HAVE_LIBC_H FALSE)
I'd place this line in the configuration file where the C/C++ flags are set for the Darwin OS. That should help you eliminate this error.
This is the answer I have posted to the same question here.
In /usr/include from the root folder there are some headers available. libc.h is one of them. I included it in my iPhoneOS SDK's usr/include folder. And it doesn't complain anymore. Figure out where to get it and add it, or remove dependencies on it.
HTH.

Resources