几乎裸iOS8.4 - >如何获取链接器? [英] Almost naked iOS8.4 --> how to get a linker?
问题描述
编辑2015-29-10。 II 。实际上, -arch armv7
而不是 -arch arm64
编辑2015-29-10。 我尝试添加。我尝试添加
export CFLAGS = - O1
export CXXFLAGS =在配置
之前的O1
同一个错误,其他文件缺少此时:
/ usr / local / cctools-arm64-port / bin / ld -demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-4f79ac.o -lstdc ++ -lSystem
ld:file not发现:N?L
我也尝试过 -O0
优化代替 -01
,结果相同。
EDIT 2015-28-10。 II。我这样做:
./ autogen.sh
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
./configure -v --host = arm-apple-darwin11 --prefix = / usr / local / lvm-cross / cctools-arm64-port
unset CC CXX
make& sudo make install
然后我在iDevice上尝试了一个简单的hello世界,testcpp.cpp包含: p>
#include< iostream>
int main()
{
std :: cout< oijo< std :: endl;
return 0;
}
编译
clang ++ -v -isysroot /usr/local/iPhoneOS8.4.sdk -target arm64-apple-darwin11 testcpp.cpp -o testcpp
这给了我:
(标签/ RELEASE_370 / final)
目标:arm64-apple-darwin11
线程模型: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_0 / CPP -ferror-limit 19 -fmessage-length 108 -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-f1de66.o -x c ++ testcpp.cpp
clang基于LLVM的-cc1版本3.7.0 3.7.0 default目标arm-apple-darwin14.0.0
忽略不存在的目录 /usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1/arm64-apple-darwin10/
忽略不存在的目录/usr/local/iPhoneOS8.4.sdk/usr/local / include
忽略不存在的目录/usr/local/iPhoneOS8.4.sdk/Library/Frameworks
#include...搜索从这里开始:
#include< ..>搜索从这里开始:
/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(框架目录)
搜索列表的结尾。
/ usr / local / cctools-arm64-port / bin / ld-demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp / var / tmp / testcpp-f1de66.o -lstdc ++ -lSystem
ld:找不到文件:4
clang ++:error:linker命令失败,退出代码为1(使用-v查看调用)
我也试过没有取消设置CC CXX
success...
编辑2015-28-10。 使用cydia解决方案建议确实工作,但我绝对想自己构建它,所以我按照 https://github.com/tpoechtrager/cctools-port 方式。因为它是太无聊获取/构建 libtool
为mac os,我切换到一个虚拟盒ubuntu 15.10 64位,其中我 sudo apt- get install
'编辑以下软件包: automake
, autogen
, libtool
, clang-3.7
, uuid-dev
llvm-3.7-dev 。然后我将 cd
编辑到 cctools
目录,并且:
./ autogen.sh
pre>
export CC =clang-3.7 -arch arm64
export CXX =clang ++ - 3.7 -arch arm64
./configure --prefix = / home / lvm-ubuntu / Desktop / iPad / cctools-produced / --host = arm-apple-darwin11
make
(完整输出位于新增gist。)
make
产生以下警告和错误:clang:warning:编译期间未使用的参数:'-arch arm64'
../include/foreign/libkern/arm/OSByteOrder.h:11:10:error:redefinition of
'_OSSwapInt16'
uint16_t _OSSwapInt16(uint16_t data)
^
../include/foreign/libkern/i386/_OSByteOrder.h:46:1:note:以前的定义
在这里是
_OSSwapInt16(
^
和模拟错误
_OSSwapInt32
和_OSSwapInt64
...我必须肯定会做错事。
< hr>
初始问题
我在iOS8中成功构建了交叉构建clang + llvm。 4在一个越狱iPad mini 3 wifi上,主要是由于以下两个问题:
http://stackoverflow.com/questions/23946851/how-to-cross-compile-clang-llvm-for-ios/
设置所有路径等,并尝试了一个
clang ++ -v testcpp.cpp -o testcpp
其中testcpp.cpp
contains:int main()
{
return 0;
}
,并且得到:
clang ++:错误:无法执行命令:可执行文件ld不存在!
clang ++:错误:linker命令失败,退出代码1(使用-v查看调用)
(整个详细输出位于此提示中。)
显然我没有GNU的
ld
,也没有任何真正的remplacement它(由llvm-clang),所以我问自己:在这种情况下我的策略是什么? (没有链接器,我甚至不能尝试建立binutils
在我的iPad上使用其ld
)。 / p>
精确:我希望链接在幕后完成,以便我可以继续做
clang ++ -v testcpp.cpp -o testcpp
,也就是说,我不想在几个步骤中手动链接。 (但脚本可以确定,即使我发现更优雅,有一个真实的ld
替换...)
备注:在llvm-clang
bin
文件夹中我有这个:XXXXs-iPad:/ usr / local / llvm-ios / bin mobile $ ls -l
total 274412
-rwxr-xr-x 1 root wheel 205456 Oct 18 12 :49 FileCheck *
-rwxr-xr-x 1 root wheel 7704096 Oct 18 12:48 bugpoint *
-rwxr-xr-x 1 root wheel 122036 Oct 18 12:48 c-index-test *
-rwxr-xr-x 1 root wheel 40802004 Oct 18 12:48 clang *
-rwxr-xr-x 1 root wheel 40802004 Oct 18 12:49 clang ++ *
-rwxr-xr -x 1 root wheel 31252792 Oct 18 12:49 clang-check *
-rwxr-xr-x 1 root wheel 1225352 Oct 18 12:49 clang-format *
-rwxr-xr-x 1 root轮671500 10月18 12:49 clang-tblgen *
-rwxr-xr-x 1根轮49684 10月18日12:49计数*
-rwxr-xr-x 1根轮22439396 10月18日12: 49 llc *
-rwxr-xr-x 1 root wheel 10351388 Oct 18 12:49 lli *
-rwxr-xr-x 1 root wheel 208140 Oct 18 12:49 lli-child-target *
-rwxr-xr-x 1 root wheel 9144692 Oct 18 12:49 llvm-ar *
-rwxr-xr-x 1 root wheel 1619592 Oct 18 12:49 llvm-as *
- rwxr-xr-x 1 root wheel 155080 Oct 18 12:49 llvm-bcanalyzer *
-rwxr-xr-x 1 root wheel 120864 Oct 18 12:49 llvm-config *
-rwxr-xr- x 1 root wheel 92232 Oct 18 12:49 llvm-config-host *
-rwxr-xr-x 1 root wheel 1604600 Oct 18 12:49 llvm-cov *
-rwxr-xr-x 1根轮1472656 Oct 18 12:49 llvm-cxxdump *
-rwxr-xr-x 1根轮1471516 Oct 18 12:49 llvm-diff *
-rwxr-xr-x 1根轮1225632 10月18 12:49 llvm-dis *
-rwxr-xr-x 1 root wheel 18342488 Oct 18 12:49 llvm-dsymutil *
-rwxr-xr-x 1 root wheel 419892 Oct 18 12:49 llvm-dwarfdump *
-rwxr-xr-x 1 root wheel 1686496 Oct 18 12:49 llvm-extract *
-rwxr-xr-x 1 root wheel 1800856 Oct 18 12:49 llvm-link *
-rwxr-xr-x 1 root wheel 10140692 Oct 18 12:49 llvm-mc *
-rwxr-xr-x 1 root wheel 138552 Oct 18 12:49 llvm-mcmarkup *
-rwxr-xr-x 1 root wheel 9144172 Oct 18 12:49 llvm-nm *
-rwxr-xr-x 1 root wheel 11554352 Oct 18 12:49 llvm-objdump *
-rwxr-xr -x 1 root wheel 220840 Oct 18 12:49 llvm-pdbdump *
-rwxr-xr-x 1 root wheel 469920 Oct 18 12:49 llvm-profdata *
-rwxr-xr-x 1 root wheel 9144692 Oct 18 12:49 llvm-ranlib *
-rwxr-xr-x 1 root wheel 1768528 Oct 18 12:49 llvm-readobj *
-rwxr-xr-x 1 root wheel 8388100 Oct 18 12:50 llvm-rtdyld *
-rwxr-xr-x 1 root wheel 1489124 Oct 18 12:50 llvm-size *
-rwxr-xr-x 1 root wheel 2106052 Oct 18 12:50 llvm -stress *
-rwxr-xr-x 1 root wheel 1610176 Oct 18 12:50 llvm-symbolizer *
-rwxr-xr-x 1 root wheel 1422732 Oct 18 12:50 llvm-tblgen *
-rwxr-xr-x 1 root wheel 1455516 Oct 18 12:50 macho-dump *
-rwxr-xr-x 1根轮71184 Oct 18 12:50 not *
-rwxr- xr-x 1 root wheel 1620520 Oct 18 12:50 obj2yaml *
-rwxr-xr-x 1 root wheel 23007212 Oct 18 12:50 opt *
-rwxr-xr-x 1 root wheel 1768416 Oct 18 12:50 verify-uselistorder *
-rwxr-xr-x 1 root wheel 402360 Oct 18 12:50 yaml2obj *
解决方案安装
org.coolstar.cctools
和org.coolstar.ld64
via Cydia。
或者,建立 https://github.com/tpoechtrager/cctools-port 。
CXX =clang ++ - arch arm64CC =clang -arch arm64./configure --host = arm-apple-darwin11
EDIT 2015-29-10. II. In fact
-arch armv7
instead of-arch arm64
and without lowering optimization, worked perfectly.EDIT 2015-29-10. I. I tried to add
export CFLAGS="-O1" export CXXFLAGS="-O1"
before
configure
, and had the same error, with a different file missing this time :"/usr/local/cctools-arm64-port/bin/ld" -demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-4f79ac.o -lstdc++ -lSystem ld: file not found: N?L
I also tried with
-O0
optimization instead of-01
, same result.EDIT 2015-28-10. II. I did this :
./autogen.sh 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" ./configure -v --host=arm-apple-darwin11 --prefix=/usr/local/lvm-cross/cctools-arm64-port unset CC CXX make && sudo make install
Then I tried a simple hello world on iDevice, with testcpp.cpp containing :
#include <iostream> int main() { std::cout << "oijo" << std::endl; return 0; }
compiled with
clang++ -v -isysroot /usr/local/iPhoneOS8.4.sdk -target arm64-apple-darwin11 testcpp.cpp -o testcpp
which gave me :
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_0/CPP -ferror-limit 19 -fmessage-length 108 -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-f1de66.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/local/cctools-arm64-port/bin/ld" -demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-f1de66.o -lstdc++ -lSystem ld: file not found: ?4 clang++: error: linker command failed with exit code 1 (use -v to see invocation)
I also tried without the
unset CC CXX
, with the same "success"...EDIT 2015-28-10. I. Using cydia solutions as suggested indeed worked, but I definitely want to build it myself, so I followed the https://github.com/tpoechtrager/cctools-port way. As it is way too boring to get/build
libtool
for mac os, I switched to a vitual box ubuntu 15.10 64 bits, where Isudo apt-get install
'ed the following packages :automake
,autogen
,libtool
,clang-3.7
,uuid-dev
andllvm-3.7-dev
. Then Icd
'ed to thecctools
directory and did :./autogen.sh export CC="clang-3.7 -arch arm64" export CXX="clang++-3.7 -arch arm64" ./configure --prefix=/home/lvm-ubuntu/Desktop/iPad/cctools-produced/ --host=arm-apple-darwin11 make
(The complete output is in the new following gist.)
make
produced the following warnings and errors :clang: warning: argument unused during compilation: '-arch arm64' ../include/foreign/libkern/arm/OSByteOrder.h:11:10: error: redefinition of '_OSSwapInt16' uint16_t _OSSwapInt16(uint16_t data) ^ ../include/foreign/libkern/i386/_OSByteOrder.h:46:1: note: previous definition is here _OSSwapInt16( ^
and analogue errors for
_OSSwapInt32
and_OSSwapInt64
... I must be for sure doing something wrong.
Initial question.
I succeed in cross-building clang+llvm for iOS8.4 on a jailbroken iPad mini 3 wifi, mainly thanks to the two following questions :
and
http://stackoverflow.com/questions/23946851/how-to-cross-compile-clang-llvm-for-ios/
Set all paths etc, and tried a
clang++ -v testcpp.cpp -o testcpp
wheretestcpp.cpp
contains :int main() { return 0; }
and got this :
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)
(the whole verbose output is in this gist.)
Obviously I don't have GNU's
ld
nor any real "remplacement" of it (by llvm-clang), so that I am asking myself : what is my strategy in this case ? (Having no linker, I can't even try to buildbinutils
on my iPad to use itsld
).Precision : I would like the linking to be done behind the scene, so that I could keep doing
clang++ -v testcpp.cpp -o testcpp
, that is, I don't want to do the linking "manually" myself in several steps. (But a script could be ok, even if I find more elegant to have a realld
replacement...)Remark : in llvm-clang
bin
folder I have this :XXXXs-iPad:/usr/local/llvm-ios/bin mobile$ ls -l total 274412 -rwxr-xr-x 1 root wheel 205456 Oct 18 12:49 FileCheck* -rwxr-xr-x 1 root wheel 7704096 Oct 18 12:48 bugpoint* -rwxr-xr-x 1 root wheel 122036 Oct 18 12:48 c-index-test* -rwxr-xr-x 1 root wheel 40802004 Oct 18 12:48 clang* -rwxr-xr-x 1 root wheel 40802004 Oct 18 12:49 clang++* -rwxr-xr-x 1 root wheel 31252792 Oct 18 12:49 clang-check* -rwxr-xr-x 1 root wheel 1225352 Oct 18 12:49 clang-format* -rwxr-xr-x 1 root wheel 671500 Oct 18 12:49 clang-tblgen* -rwxr-xr-x 1 root wheel 49684 Oct 18 12:49 count* -rwxr-xr-x 1 root wheel 22439396 Oct 18 12:49 llc* -rwxr-xr-x 1 root wheel 10351388 Oct 18 12:49 lli* -rwxr-xr-x 1 root wheel 208140 Oct 18 12:49 lli-child-target* -rwxr-xr-x 1 root wheel 9144692 Oct 18 12:49 llvm-ar* -rwxr-xr-x 1 root wheel 1619592 Oct 18 12:49 llvm-as* -rwxr-xr-x 1 root wheel 155080 Oct 18 12:49 llvm-bcanalyzer* -rwxr-xr-x 1 root wheel 120864 Oct 18 12:49 llvm-config* -rwxr-xr-x 1 root wheel 92232 Oct 18 12:49 llvm-config-host* -rwxr-xr-x 1 root wheel 1604600 Oct 18 12:49 llvm-cov* -rwxr-xr-x 1 root wheel 1472656 Oct 18 12:49 llvm-cxxdump* -rwxr-xr-x 1 root wheel 1471516 Oct 18 12:49 llvm-diff* -rwxr-xr-x 1 root wheel 1225632 Oct 18 12:49 llvm-dis* -rwxr-xr-x 1 root wheel 18342488 Oct 18 12:49 llvm-dsymutil* -rwxr-xr-x 1 root wheel 419892 Oct 18 12:49 llvm-dwarfdump* -rwxr-xr-x 1 root wheel 1686496 Oct 18 12:49 llvm-extract* -rwxr-xr-x 1 root wheel 1800856 Oct 18 12:49 llvm-link* -rwxr-xr-x 1 root wheel 10140692 Oct 18 12:49 llvm-mc* -rwxr-xr-x 1 root wheel 138552 Oct 18 12:49 llvm-mcmarkup* -rwxr-xr-x 1 root wheel 9144172 Oct 18 12:49 llvm-nm* -rwxr-xr-x 1 root wheel 11554352 Oct 18 12:49 llvm-objdump* -rwxr-xr-x 1 root wheel 220840 Oct 18 12:49 llvm-pdbdump* -rwxr-xr-x 1 root wheel 469920 Oct 18 12:49 llvm-profdata* -rwxr-xr-x 1 root wheel 9144692 Oct 18 12:49 llvm-ranlib* -rwxr-xr-x 1 root wheel 1768528 Oct 18 12:49 llvm-readobj* -rwxr-xr-x 1 root wheel 8388100 Oct 18 12:50 llvm-rtdyld* -rwxr-xr-x 1 root wheel 1489124 Oct 18 12:50 llvm-size* -rwxr-xr-x 1 root wheel 2106052 Oct 18 12:50 llvm-stress* -rwxr-xr-x 1 root wheel 1610176 Oct 18 12:50 llvm-symbolizer* -rwxr-xr-x 1 root wheel 1422732 Oct 18 12:50 llvm-tblgen* -rwxr-xr-x 1 root wheel 1455516 Oct 18 12:50 macho-dump* -rwxr-xr-x 1 root wheel 71184 Oct 18 12:50 not* -rwxr-xr-x 1 root wheel 1620520 Oct 18 12:50 obj2yaml* -rwxr-xr-x 1 root wheel 23007212 Oct 18 12:50 opt* -rwxr-xr-x 1 root wheel 1768416 Oct 18 12:50 verify-uselistorder* -rwxr-xr-x 1 root wheel 402360 Oct 18 12:50 yaml2obj*
解决方案Install
org.coolstar.cctools
andorg.coolstar.ld64
via Cydia.Or, alternatively, build https://github.com/tpoechtrager/cctools-port by hand.
CXX="clang++ -arch arm64" CC="clang -arch arm64" ./configure --host=arm-apple-darwin11
这篇关于几乎裸iOS8.4 - >如何获取链接器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!