Im trying to build Botan-1.10.12 for iOS (arch arm64) with Xcode 7.3.1.
I tried to follow the guidelines on Botan's website: https://github.com/randombit/botan/blob/master/doc/manual/building.rst#for-ios-using-xcode
With some changes, I managed to build for armv7 doing the following:
./configure.py --prefix="armv7" --cpu=armv7 --with-zlib --cc=clang --cc-bin="clang++ -arch armv7"
sudo xcrun --sdk iphoneos make install
But when I try to do the same for arm64:
./configure.py --prefix="arm64" --cpu=arm64 --with-zlib --cc=clang --cc-bin="clang++ -arch arm64"
I get the following error:
ERROR: Unknown or unidentifiable processor "arm64"
And I get the same error if I try to change arm64 to armv8-a like the guidelines suggest:
ERROR: Unknown or unidentifiable processor "armv8-a"
I alse tried with --cpu=arm:
configure.py --prefix="arm64" --cpu=arm --with-zlib --cc=clang --cc-bin="clang++ -arch arm64"
and that works for the configure step, but then when I run sudo xcrun --sdk iphoneos make install, I get the following error:
In file included from src/asn1/asn1_alt.cpp:16:
In file included from build/include/botan/loadstor.h:13:
build/include/botan/bswap.h:58:11: error: unknown register name 'r3' in asm
: "r3", "cc");
^
1 error generated.
make: *** [build/lib/asn1_asn1_alt.o] Error 1
Im not that familiar with building stuff for iOS. How can I build Botan for arm64 iOS?
Thanks!
Related
I'm trying to compile a project developed in C language for iOS devices. It uses custom library file, libcurl, libcrypto, libssl and libpthread. I have successfully compiled it for Mac OS X, but having issues compiling it for iOS. Also, any help I try to find online is more of Xcode GUI help, and I need command line help for it. Need to compile it through commands instead of Xcode GUI.
First it needs to compile couple of C files, then make a static library file out of these compiled files, which further used when compiling a native binary.
This is how I generated iOS arm ouptut files from c files inside file01:
Store the iphoneos sdk path in environemnt variable:
CC="$(xcrun --sdk iphoneos9.2 --find clang) -isysroot $(xcrun --sdk iphoneos9.2 --show-sdk-path) -arch armv7 -arch armv7s -arch arm64 -arch armv6 -arch arm64"
Compile the c files in file01 with command:
$CC -c -O2 *.c
To check which architect these files are compiled for can be checked with this lipo command. Example:
$ lipo -info example_file01.o
Architectures in the fat file: example_file01.o are: armv7 armv7s armv6 arm64
To make a static library file I can get iOS ar file path using command:
$ xcrun --sdk iphoneos9.2 --find ar /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
I could store the path in an environment variable, but it was not working throwing error not recognising ar command arguments rcu. So, used the ar path instead to create the library file with this command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar rcu ../output/libfile01.a *.o
If checking which architectures this lib file supports it gives this output:
$ lipo -info ../output/libfile01.a
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: archive with no architecture specification: ../output/libfile01.a (can't determine architecture for it)
But, it should have given output similar to this one:
$ lipo -info ../ios/lib/libcurl.a
Architectures in the fat file: ../ios/lib/libcurl.a are: i386 armv7 armv7s x86_64 arm64
This is causing error when trying compiling files in using the generated static lib file with command:
$CC -o ../output/FinalProjectFile -O2 *.c ../output/libfile01.a ../ios/lib/libcurl.a ../ios/lib/libssl.a ../ios/lib/libcrypto.a -lpthread -lm
Error: ld: warning: ignoring file ../output/libfile01.a, file was built for archive which is not the architecture being linked (armv7): ../output/libfile01.a
Thanks for help
I finally solved the issue by using different argument for ar.
Instead of using
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar rcu ../output/libfile01.a *.o
used
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar -rcs ../output/libfile01.a *.o
The only difference was it's -rcs instead of rcu.
When checking the info of this libfile it shows the output like this:
$ lipo -info ../output/libfile01.a
Architectures in the fat file: ../output/libfile01.a are: armv7 armv7s armv6 arm64
Recently I was asked to creat a CI system, so I tride to use xcodebuild.
But I got Errors, the command is :xcodebuild -sdk iphoneos -configuration Release clean build
Errors:
ld: library not found for -lFMDB
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld build/ProjectName.build/Release-iphoneos/ProjectName.build/Objects-normal/armv7/ProjectName normal armv7
Ld build/ProjectName.build/Release-iphoneos/ProjectName.build/Objects-normal/arm64/ProjectName normal arm64
I import FMDB by cocoa pods, and Header Search Path has this path "${PODS_ROOT}/Headers/Public/FMDB".
Please help me,thx very much.
I need to compile Fortran-77 subroutines to be accessible on iOS. I am using GCC with the DragonEgg plugin, so I can use gfortran with the LLVM backend. I followed this answer but I am stuck when it comes to build libgfortran for armv7, armv7s and arm64.
Can I build libgfortran alone or is it always necessary to compile the GCC suite completely?
What is the correct way of producing this library for a different target? Is it possible to use GCC for this step or do I need LLVM for the arm*-targets?
Building GCC with arm-targets using GCC I get these errors:
./configure --prefix=/tmp/out --host=arm-apple-darwin --enable-languages=fortran
make
…
make[2]: arm-apple-darwin-ar: No such file or directory
make[2]: *** [libiberty.a] Error 1
make[1]: *** [all-libiberty] Error 2
Building GCC with arm-targets using LLVM I have problems with configure:
export CC="$(xcrun -sdk iphoneos -find clang)"
export CPP="$CC -E"
export CFLAGS="-arch armv7 -arch armv7s -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=9.2"
export AR=$(xcrun -sdk iphoneos -find ar)
export RANLIB=$(xcrun -sdk iphoneos -find ranlib)
export CPPFLAGS="-arch armv7 -arch armv7s -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=9.2"
export LDFLAGS="-arch armv7 -arch armv7s -arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
./configure --prefix=/tmp/out --enable-languages=fortran --host=arm-apple-darwin --disable-shared
…
checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E
configure: error: in `/Users/timo/temp/gcc-4.8.5-build/fixincludes':
configure: error: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E" fails sanity check
See `config.log' for more details.
make[1]: *** [configure-fixincludes] Error 1
The configure script states that
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
What is meant by If a cross compiler is detected? How do I define the target platform correctly?
LLVM uses -arch armv7 etc. as target definition. What is nedded when using GCC?
You are trying to build cross-gcc libraries without cross binutils. Here is a good manual for building cross-gcc for arm, you can follow it.
What is meant by If a cross compiler is detected? How do I define the
target platform correctly?
When configuring you should also set --target=arm-apple-darwin. (In my own experience I did not set --host at all)
make[2]: arm-apple-darwin-ar: No such file or directory
Before building arm cross-compiler target libraries you should build binutils for this target.
Can't say anything about llvm.
So just try to make all steps in the link above.
I have tried to install GMP Library Version 6.1.0 for iOS9.
I need to compile GMP in iOS for a math project. My configuration command was like this.
./configure CC=clang CPP="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -E" CPPFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/ -fembed-bitcode -miphoneos-version-min=7.0 -arch armv7 -target arm-apple-darwin" --host=aarch64-apple-darwin --disable-assembly --enable-static --disable-shared --disable-thread-safe --enable-cxx
Found this configure option in :This link.
Here is my environment details:
Mac OSX 10.11.2; Xcode7.2; iOS SDK 9.2
During "configure" state it shows one warning
configure: WARNING: unrecognized options: --disable-thread-safe
But it configures without any error.
Configure summary:
configure: summary of build options:
Version: GNU MP 6.1.0
Host type: aarch64-apple-darwin
ABI: standard
Install prefix: /usr/local
Compiler: clang
Static libraries: yes
Shared libraries: no
After that I run make command.
Then make check.
While running make check command it gives the following error.
or, in text form:
/bin/sh ../libtool --tag=CC --mode=link clang -mfpu=neon -O2 -pedantic -DNO_ASM -o t-bswap t-bswap.o libtests.la ../libgmp.la
libtool: link: clang -mfpu=neon -O2 -pedantic -DNO_ASM -o t-bswap t-bswap.o ./.libs/libtests.a [redacted]/Documents/gmp-6.1.0/.libs/libgmp.a ../.libs/libgmp.a
ld: warning: ld: warning: ignoring file ./.libs/libtests.a, file was built for archive which is not the architecture being linked (x86_64): ./.libs/libtests.aignoring file t-bswap.o, file was built for armv7 which is not the architecture being linked (x86_64): t-bswap.o
ld: warning: ignoring file [redacted]/Documents/gmp-6.1.0/.libs/libgmp.a, file was built for archive which is not the architecture being linked (x86_64): /Users/[redacted]/Documents/gmp-6.1.0/.libs/libgmp.a
ld: warning: ignoring file ../.libs/libgmp.a, file was built for archive which is not the architecture being linked (x86_64): ../.libs/libgmp.a
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [t-bswap] Error 1
make[3]: *** [check-am] Error 2
make[2]: *** [check-recursive] Error 1
make[1]: *** [check-recursive] Error 1
make: *** [check] Error 2
I am stuck here. Your help is highly appreciated.
[EDITED]
I'm trying to compile GNU bash 4.3.30 on (and for) my iPad 2, iOS 8.4 using Clang, ld64, cctools, GNU make and the iOS 8.1 SDK. When processing bashversion, Clang is "unable to execute dsymutil", and reports that it "doesn't exist", exiting with error 1.
$ make
(...)
"/usr/bin/ld" -demangle -dynamic -arch armv7 -iphoneos_version_min 5.0.0 -syslibroot /var/mobile/iPhoneOS8.1.sdk -o bashversion -lcrt1.3.1.o -L./lib/termcap /var/tmp/bashversion-814fa1.o buildversion.o -lSystem
"dsymutil" -o bashversion.dSYM bashversion
clang: error: unable to execute command: Executable "dsymutil" doesn't exist!
clang: error: dsymutil command failed with exit code 1 (use -v to see invocation)
make: *** [bashversion] Error 1
$ echo $CC
clang --sysroot /var/mobile/iPhoneOS8.1.sdk -v
$ clang --version
clang version 3.5.0 (trunk)
Target: armv7-apple-darwin-14.0.0
Thread model: posix
$ ld -v
#(#)PROGRAM:ld PROJECT:ld64-
configured to support archs: i386 x86_64 armv4t armv5 armv6 armv7 armv7f armv7k armv8 arm64 arm64v8
$ which dsymutil
$ dsymutil
-sh: dsymutil: command not found
$ find / -name dsymutil
$
Apparently, my iPad has no dsymutil. So, where can I find one? Does it come with Xcode? Or is there any way to compile GNU bash 4.3.30 without it?
Dsymutil is a closed source tool, and is not available for iOS.
But that's not much of a problem, just create a symlink to /bin/true,
i.e.
ln -s /bin/true /usr/bin/dsymutil