It is easy to install Python and jail breaking and installing Cydia:
sudo apt-get install python
It is a little more complex to install Perl. You should follow instructions here to add a new repository and its GPG key.
It is easy to install Python and jail breaking and installing Cydia:
sudo apt-get install python
It is a little more complex to install Perl. You should follow instructions here to add a new repository and its GPG key.
After jail-breaking your iPhone, you can install CyDelete from Cydia. This also brings you apt-get and apt-cache.
很不好意思的,在把 iPhone 4 变成一台开发机之后,我的一个误操作把它变成了砖头机:
为了把 XCode 里 iPhone SDK 中的 header files 和 library files 拷贝到我的 iPhone 上(这么干好像是违反 iPhone 和 XCode users licence 的),我想敲两个命令:
sudo mv /usr/lib /usr/lib.bak sudo ln -s ~/Media/iPhoneSDK/lib /usr/lib
结果很不幸的,第一个命令一敲完,系统就死了。(我没有在 Linux 或者 FreeBSD 上这么干过,不知道这俩会不会死。)
随后用 macbook 上的 iTunes 回复 iPhone 的系统。不知什么原因,我开会回来时,发现雪上加霜—— iPhone 砖头了。而且屏幕上是花的,无法关机。
于是开始了慢慢长征路:先找卖给我这个 iPhone 的中关村小铺,说无解。于是去西单大悦城的苹果店的 Genius Bar,说我买的是港版,没有发票也无法开机,不给保修。于是去了一家苹果指定维修店,一看77个人排队在我前头,而且唯一的工程师甩着淳朴的京片儿,一副憨憨的无知少年的样子。
最关键的是:在这些地方都没有看到我心中设想的高级维修设备,工程师们也都是用笔记本电脑连上 iPhone 修理。于是哥们儿心说,既然有按照百度开方子的医生,何不在自己动手 google 一下呢?难道维修工程师们的英语水平比哥这个开发工程师还牛了去了?!
于是发现可以进入 DFU mode(怎么进入请 Google)然后 iPhone 就又能被 iTunes 发现并且 restore 了。DFU mode 是执行 firmware 中的程序,但是不引导操作系统。
但是 restore 很不好意思的又失败了;给出一个错误消息说:error 3004。继续 Google,发现这里有(http://support.apple.com/kb/TS3694)各种error code 的应对方法。在执行了一个神妙命令之后,再次 restore 成功。
随后还从 iTunes 的备份中恢复了通信录、短信记录、以及配置好的邮箱和邮件等重要信息。
准备明天再次翻墙。这次要不仅要装 gcc 4.2 和 Google Go for iOS,还立志要把 Clang/LLVM 移植到 iPhone 4 上来!
iPhone 和 iPad 内部基本上是 CMU 的 Mach 内核上运行着的 NetBSD 操作系统服务。从这些出色的操作系统技术来看, iPhone 和 iPad 不逊色于任何一款电脑。
自从买了 iPhone 4,我一直在琢磨着怎么怎么把它变得跟一台开发用的电脑一样,比如像装了开发环境(Homebrew)的 Mac MINI 一样。从 Apple Store 上买了一根 iPhone/iPad to VGA 适配电缆之后,我的 iPhone 可以输出到电视和显示器。在 jailbreak 工具(redsn0w)和 Cydia 的帮助下,我可以把 iPhone 和无线键盘、无限鼠标连接起来。我还安装了 iPhone 上的 Mobile Terminal 和一些常用的工具程序,包括和 awk 和 vim。随后,感谢牛鼻的黑客们提供了 GCC 4.2 和 Google Go compiler 的 iPhone 版本。然后呢,用 iPhone 写程序大概就是这个样子的(我其实可以把 iPhone 横过来,这样更能充分利用电视宽屏的空间;图中配角男还应该减减肥):
在 iPhone 上用 vim 编辑 C 语言和 Go 语言程序的样子如下:
编译和运行程序的样子是这样的:
附上一些秘笈:
Following this blog post: http://blog.syshalt.net/index.php/2010/09/12/compile-c-applications-with-gcc-on-ios-4-iphone/, I installed GCC 4.2.1 on my iPhone and gcc works. However, g++ does not. Moreover, above post does not explain how comes the header files and library files for gcc on iPhone.
This post complements above post by adding the part about C++. First of all, I copy-and-pastes above post.
———————————————-
Here is what you need to do in order to be able to compile and run a C application on iphone:
1. You will need to Jailbreak the iPhone first, search on google for more info.
2. Install OpenSSH from Cydia.
3. Connect iPhone to your wireless network and SSH to it.
4. Download this application using: wget http://www.syshalt.net/pub/iphone/gcc-iphone/fake-libgcc_1.0_iphoneos-arm.deb
5. Install libcc using: dpkg –i fake-libgcc_1.0_iphoneos-arm.deb
6. Install iphone-gcc using this command: apt-get install iphone-gcc
(you can download this version from my website: iphone-gcc if does not work on your device the one that is installed by default)
7. Download using: wget http://www.syshalt.net/iphone/gcc-iphone/sdk-2.0-headers.tar.gz
8. Untar with command: tar -xvzf sdk-2.0-headers.tar.gz
9. Enter in the new created folder with: cd include-2.0-sdk-ready-for-iphone
10. Copy all files to include folder with command: cp –r * /usr/include
11. Now type: cd .. in order to return to the previous folder
12. Download using: wget http://www.syshalt.net/iphone/gcc-iphone/gcc_files.tar.gz
13. Untar with command: tar -xvzf gcc_files.tar.gz
14. Enter in the new created folder with command: cd gcc_files
15. Copy all files to /usr/lib using command: cp –r * /usr/lib
16. Install ldid to sign the application (this will prevent iOS to kill the application at startup) using: apt-get install ldid
17. Sign your compilet aplication using: ldid –S <application>
18. Run the application using: ./<application>
——————————————–
From step 9 to step 15, it explains how to install C header files and library files. These files can be copied from the iPhone SDK. On my MacBook, I have Xcode 4.1 and iPhone SDK 4.3, which resides in the directory:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
I just package the usr subdirectory and throw it to my iPhone:
tar cjf iPhoneOS4.3.sdk-usr.tar.bz2 \ /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr scp iPhoneOS4.3.sdk-usr.tar.bz2 mobile@:/var/mobile/Media/
Then, on my iPhone, I unpack the tarball and installed the packing using the following commands:
cd /var/mobile/Media tar xjf iPhone4.3.sdk-usr.tar.bz2 cd /usr/local sudo ln -s /var/mobile/Media/iPhoneOS4.3.sdk-usr/include cd /usr/lib sudo ln -s /var/mobile/Media/iPhoneOS4.3.sdk-usr/lib/libSystem.B.dylib sudo ln -s /var/mobile/Media/iPhoneOS4.3.sdk-usr/lib/libSystem.dylib sudo ln -s /var/mobile/Media/iPhoneOS4.3.sdk-usr/lib/libgcc_s.1.dylib sudo rmdir system sudo ln -s /var/mobile/Media/iPhoneOS4.3.sdk-usr/lib/system for i in /var/mobile/Media/iPhoneOS4.3.sdk-usr/lib/libstdc++*; do \ sudo ln -s $i; done
It is now the time to test g++. Using the following command:
g++ hello.cc -o hello \ -I /usr/local/include/c++/4.2.1/ \ -I /usr/local/include/c++/4.2.1/armv7-apple-darwin10
I successfully built the following simple C++ program:
#include <stdio.h>
int main() {
std::cout << "Hello World!";
return 0;
}