EDIT, 2015-10-24. This finally worked :
../configure --prefix=/usr/local/lvm-cross/llvm-ios --with-default-sysroot=/usr/local/iPhoneOS8.4.sdk --host=arm-apple-darwin11 --enable-optimized --disable-assertions --disable-libedit
with
clang -isysroot /usr/local/iPhoneOS8.4.sdk/ -target arm64-apple-darwin11 testcpp.cpp -o testcpp
where testcpp.cpp
contains :
int main()
{
return 0;
}
Now if I modfified the source code simply as follows :
#include <iostream> // I am not even calling << operator in code, just including
int main()
{
return 0;
}
the following problem appears :
Undefined symbols for architecture arm64:
"std::ios_base::Init::Init()", referenced from:
___cxx_global_var_init in testcpp-0b9c00.o
"std::ios_base::Init::~Init()", referenced from:
___cxx_global_var_init in testcpp-0b9c00.o
ld: symbol(s) not found for architecture arm64
Verbosity with -v
gives this :
XXXXs-iPad:~/Documents/CODING/MY/TESTS/CPP mobile$ clang -v -isysroot /usr/local/iPhoneOS8.4.sdk -target arm64-apple-darwin11 testcpp.cpp -o testcpp
clang version 3.7.0 (tags/RELEASE_370/final)
Target: arm64-apple-darwin11
Thread model: posix
"/usr/local/llvm-ios/bin/clang" -cc1 -triple arm64-apple-ios5.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name testcpp.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -target-cpu generic -target-feature +neon -target-abi darwinpcs -target-linker-version 253.3.3 -v -dwarf-column-info -resource-dir /usr/local/llvm-ios/bin/../lib/clang/3.7.0 -isysroot /usr/local/iPhoneOS8.4.sdk -fdeprecated-macro -fdebug-compilation-dir /var/mobile/Documents/CODING/MY/TESTS/CPP -ferror-limit 19 -fmessage-length 132 -stack-protector 1 -mstackrealign -fallow-half-arguments-and-returns -fblocks -fobjc-runtime=ios-5.0.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/tmp/testcpp-b164d6.o -x c++ testcpp.cpp
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target arm-apple-darwin14.0.0
ignoring nonexistent directory "/usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1/arm64-apple-darwin10/"
ignoring nonexistent directory "/usr/local/iPhoneOS8.4.sdk/usr/local/include"
ignoring nonexistent directory "/usr/local/iPhoneOS8.4.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1
/usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1/backward
/usr/local/llvm-ios/bin/../lib/clang/3.7.0/include
/usr/local/iPhoneOS8.4.sdk/usr/include
/usr/local/iPhoneOS8.4.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/usr/bin/ld" -demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-b164d6.o -lSystem
Undefined symbols for architecture arm64:
"std::ios_base::Init::Init()", referenced from:
___cxx_global_var_init in testcpp-b164d6.o
"std::ios_base::Init::~Init()", referenced from:
___cxx_global_var_init in testcpp-b164d6.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
EDIT, 2015-10-21. This time I configured with :
../configure --prefix=/usr/local/lvm-cross/llvm-ios --target=arm-apple-darwin11 --host=arm-apple-darwin11 --with-default-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk --enable-optimized --disable-assertions --disable-libedit
Trying to compile with clang++ -v testcpp.cpp -o testcpp
again throws then the following error :
"ld" -demangle -dynamic -arch armv4t -macosx_version_min 10.10.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-bb42e7.o -lc++ -lSystem
arm-apple-darwin11-clang++: error: unable to execute command: Executable "ld" doesn't exist!
arm-apple-darwin11-clang++: error: linker command failed with exit code 1 (use -v to see invocation)
I still have this -macosx_version_min 10.10.0
stuff : bad moon rising ; worrying. Installing org.coolstar.cctools
and org.coolstar.ld64
via Cydia and recompiling gave :
"/usr/bin/ld" -demangle -dynamic -arch armv4t -macosx_version_min 10.10.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-5ae1b0.o -lc++ -lSystem
ld: library not found for -lc++
arm-apple-darwin11-clang++: error: linker command failed with exit code 1 (use -v to see invocation)
still the ld: library not found for -lc++
error. Note that adding -isysroot=/path/to/the/iphonesdk/that/i/copied/from/my/mac/to/my/idevice
to the compilation did not change a single thing to what I have stated above.
EDIT, 2015-10-18, IV. Installing the package "Darwin CC Tools" from the BigBoss source via cydia furnishes the ld
command line executable. Trying to compile with clang++ -v testcpp.cpp -o testcpp
again throws then the following error :
"/usr/bin/ld" -demangle -dynamic -arch armv4t -macosx_version_min 10.10.0 -o testcpp /var/tmp/testcpp-ddd8d4.o -lc++ -lSystem
ld: library not found for -lc++
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
I guess that it means that ld
can't find the place where the c++
standard library files are. How to deal with this ?
EDIT, 2015-10-18, III. Retrospectively I think there must be an issue with the configure
step. On the iPad when I try to compile with clang++ -v testcpp.cpp -o testcpp
it produce a natural error saying that ld
is missing, but it shows something strange : "ld" -demangle -dynamic -arch armv4t -macosx_version_min 10.10.0 -o testcpp /var/tmp/testcpp-a74741.o -lc++ -lSystem
What does this -macosx_version_min 10.10.0
do here ? It is as if the compiler was looking for the (mac os) linker of the plateform it was cross-build with instead of the iOS one...
EDIT, 2015-10-18, II. Actually I copied the whole iOS8.4 sdk to the iPad, and I will -isysroot
to it during compilation. I tried to compile the simplest c++ code
int main()
{
return 0;
}
in testcpp.cpp
with clang++ -v testcpp.cpp -o testcpp
which led to a natural linking error (as I don't have a linker yet !) :
clang++: error: unable to execute command: Executable "ld" doesn't exist!
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
As I don't know which strategy to opt for, I created a question :
Almost naked iOS8.4 --> how to get a linker?
EDIT, 2015-10-18, I. Passing --disable-libedit
at the configure step allowed me to elude the 'histedit.h' file not found
error. Had then again a crt_externs.h file not found
error in ProgramTest.cpp
that I get rid of by commenting the #include
, which led to this error
/Users/XXXX/Documents/CODING/src-cross/clang/llvm-3.7.0.src/unittests/Support/ProgramTest.cpp:62:18: error:
use of undeclared identifier '_NSGetEnviron'
char **envp = *_NSGetEnviron();
^
that I fixed by simply putting char **envp = NULL;
(drastic). The make
went then like a charm, as well as obvioulsy the sudo make install
. Then I scp
ed the whole directory to my iPad, and tried /usr/local/llvm-ios/bin/clang
which told me... clang: error: no input files
. Success. ;-) Now, as the install is naked, I need to find all standard libraries (iostream etc)...
EDIT, 2015-10-17. After Thomas suggested it I tried this (just used 8.4 instead of 8.3 sdk as my jailbroken ipad mini 3 wifi is under iOS 8.4) :
curl -O http://llvm.org/releases/3.7.0/llvm-3.7.0.src.tar.xz
tar -Jxf llvm-3.7.0.src.tar.xz
cd llvm-3.7.0.src/tools/
curl -O http://llvm.org/releases/3.7.0/cfe-3.7.0.src.tar.xz
tar -Jxf cfe-3.7.0.src.tar.xz
mv cfe-3.7.0.src clang
cd ..
export CC="clang -arch arm64 -mios-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk"
export CXX="clang++ -arch arm64 -mios-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk"
mkdir build && cd build
To avoid the following error :
/Users/XXX/Documents/CODING/src-cross/clang/llvm-3.7.0.src/utils/unittest/googletest/src/gtest-death-test.cc:40:12: fatal error: 'crt_externs.h' file not found
# include <crt_externs.h>
^
Thomas warns us about in the post How to cross-compile clang/llvm for iOS?, I went to /Users/XXX/Documents/CODING/src-cross/clang/llvm-3.7.0.src/utils/unittest/googletest/src/gtest-death-test.cc
and commented the #include <crt_externs.h>
. Then I found the char** GetEnviron()
function in
# if GTEST_OS_MAC
inline char** GetEnviron() {
// When Google Test is built as a framework on MacOS X, the environ variable
// is unavailable. Apple's documentation (man environ) recommends using
// _NSGetEnviron() instead.
return *_NSGetEnviron();
}
and replaced the orignal return *_NSGetEnviron();
with return NULL;
. Then I continued with the configure
, the unset
and the make VERBOSE=1 -j
:
../configure --prefix=/usr/local/XXX-cross/llvm-ios --host=arm-apple-darwin11 --enable-optimized --disable-assertions
unset CC CXX
make VERBOSE=1 -j
The latter triggered the following error :
/Users/XXXX/Documents/CODING/src-cross/clang/llvm-3.7.0.src/lib/LineEditor/LineEditor.cpp:17:10: fatal error: 'histedit.h' file not found
#include <histedit.h>
^
which I don't know how to tackle...
Initial question. I am trying to cross-compile clang/llvm 3.7.0 for iOS8.x on ipad mini 3, with the help of the following :
How to cross-compile clang/llvm for iOS?
I have tried this :
curl -O http://llvm.org/releases/3.7.0/llvm-3.7.0.src.tar.xz
tar -Jxf llvm-3.7.0.src.tar.xz
cd llvm-3.7.0.src/tools/
curl -O http://llvm.org/releases/3.7/clang-3.7.src.tar.gz
tar -Jxf cfe-3.7.0.src.tar.xz
mv cfe-3.7.0.src clang
cd ..
export CC="clang -arch armv8a -mios-version-min=8.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk"
export CXX="clang++ -arch armv8a -mios-version-min=8.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk"
mkdir build && cd build
../configure --prefix=/usr/local/XXX-cross/llvm-ios --host=armv8a-apple-darwin-eabi --enable-optimized --disable-assertions
without success, having the
error: invalid arch name '-arch armv8a'
And I had this kind of error for all arch
's and host
's I've tried related to my iPad mini 3, for which I found infos here and there.
I had the same kind of problem when I tried to build gcc for my iPad mini 3, and I have the impression that at the moment, whatever compiler I am trying to "cross-build" for this target, the correct host
& arch
options are not supported.
I am wrong ? I there a way to pass other options dealing with generic/unknown arch
's & host
's, that with suitable other options, would give me workable llvm-clang on my iPad mini 3 ?