IPhone development BASICS (3)-build an iPhone OS3.1.2 Development Environment on Linux

Source: Internet
Author: User

Author: Yi Feiyang

First time: http://www.bkjia.com/kf/201110/425927.htmlwe introduced the environment configuration for developing iPhone application standards based on Intel Mac. Although Mac is cheap, most people are still using windows and linux systems. Today we will introduce how to build an iPhone Development System on linux. The latest SDK version 3.1.2 is used here (as ).

This section describes how to install and configure windows (Cygwin) in linux.

My HOST machine environment is as follows:
$ Uname-
Linux localhost. localdomain 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:54:20 EDT 2006 i686 i686 i386 GNU/Linux

$ Gcc-v
Using built-in specs.
Target: i386-redhat-linux
Config option :.. /configure -- prefix =/usr -- mandir =/usr/share/man -- infodir =/usr/share/info -- enable-shared -- enable-threads = posix -- enable-checking = release -- with-system-zlib -- enable-_ cxa_atexit -- disable-libunwind-exceptions -- enable-libgcj-multifile -- enable-versions ages = c, c ++, objc, obj-c ++, java, fortran, ada -- enable-java-awt = gtk -- disable-dssi -- enable-plugin -- with-java-home =/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre -- with-cpu = generic -- host = i386-redhat-linux
Thread model: posix
Gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)

Something to prepare:

3.1.2 use restore file iPhone1, 2_3.1.2_7D11_Restore.ipsw
IPhone3.1.2 SDK iphone_sdk_3.1.2_with_xcode_3.1.4 _ leopard _ 9m2809. dmg
Many websites have introduced it. Here we also use toolchain to build the environment. Refer to iphonedevonlinux.

Checkout toolchain
$ Mkdir ~ /Toolchain
$ Cd ~ /Toolchain
$ Svn checkout http://iphonedevonlinux.googlecode.com/svn/trunk ./

# Copy the SDK and firmware file
$ Mkdir-p files/firmware
$ Mv./iphone_sdk_3.1.2_with_xcode_3.1.4 _ leopard _ 9m2809. dmg./files/
$ Mv./iPhone1, 2_3.1.2_7D11_Restore.ipsw./files/firmware/

Today (2010/2/9), the updated toolchain already corresponds to the SDK version 3.1.2, so you don't need to patch it. (Thanks to wzhao)

※If you encounter a problem with "We need the decryption key for 018-6028-014.dmg .",
DECRYPTION_KEY_SYSTEM = $ ...... replace it with DECRYPTION_KEY_SYSTEM = "encryption"

Because the toolchain for checkout is for version 3.0 and cannot be used directly, a patch is required. Download the patch here and go to the toolchain directory:

$ Patch <toolchain. sh. patch
$ Chmod u + x toolchain. sh

Install/compile
After executing./toolchain. sh all, We will install and compile it all, but there are actually many problems, so we will continue step by step.

# Step 1: No problem
$./Toolchain. sh headers
# The second step passes smoothly
$./Toolchain. sh firmware
# Step 3 is smooth
$./Toolchain. sh darwin_sources
# Note the last step.
$./Toolchain. sh build

Execute the last step to compile the gcc-4.2-iphone and the following error will occur during the link:

Ld: library not found for-lc
Collect2: ld returned 1 exit status
Make [3]: *** [libgcc_s.dylib] error 1
....
Make [2]: *** [stmp-multilib] error 2
Rm gcov. pod fsf-funding.pod gfdl. pod gpl. pod cpp. pod gcc. pod
....
Make [1]: *** [all-gcc] error 2
Make [1]: leaving dir '/home/xxx/toolchain/bld/gcc-4.2-iphone'
Make: *** [all] error 2
 

To solve this problem, run the following command in the toolchain directory:

Cp. /sdks/iPhoneOS3.1.2.sdk/usr/lib/libSystem. b. dylib. /toolchain/bld/gcc-4.2-iphone/gcc/libc. dylib is executed next time. /toolchain. sh build. The following figure shows the success.

It seems like the toolchain built! Finally, you can execute./toolchain. sh clean to delete files such as the files and sdks in the compilation process.

Test
Next, you can first try the toolchain/apps/test code HelloToolchain below.

The following problems may occur during compilation ::
1. compiler file arm-apple-darwin9-gcc not found

Make is directly in the HelloToolchain directory. Probably prompts that there are no commands such as arm-apple-darwin9-gcc. This is because no compiler path is set. Put the following statement into the/etc/profile (for all users) or the. bash_profile file.

Export PATH =/home/xxx/toolchain/pre/bin: $ PATH2. Frameworks is prompted during compilation, or the header file cannot be found.

Classes/ClockAppDelegate. m: 10: 38: error: AVFoundation/AVFoundation. h: no such file or directory
Make: *** [Classes/ClockAppDelegate. o] Error 1 or a connection prompt is displayed:

Ld: library not found for-lobjc
Collect2: ld returned 1 exit status
Make: HelloWorldFirst? Error 1 first check whether the path of the library file and header file is configured in your makefile file, such as the following settings:
# IPhone SDK path
IPHONESDK =/home/xxx/toolchain/sys
# Include path (SDK)
INCPATH + =-I "$ (IPHONESDK)/usr/include"
# Include path (gcc)
INCPATH + =-I "$ (IPHONESDK)/usr/include/gcc/darwin/4.2"

CFLAGS + = $ (INCPATH )\
...

LDFLAGS + =-L "$ (IPHONESDK)/usr/lib"
LDFLAGS + =-F "$ (IPHONESDK)/System/Library/Frameworks"
LDFLAGS + =-F "$ (IPHONESDK)/System/Library/PrivateFrameworks"

CFLAGS + =-F "$ (IPHONESDK)/System/Library/Frameworks"
CFLAGS + =-F "$ (IPHONESDK)/System/Library/PrivateFrameworks"

If the problem persists, you can obtain the latest version library and header file in the following two ways:

Method 1
Download dyldcache, use scp and other tools to send it to the iPhone, and then execute:

IPhone $./dyldcache/System/Library/Caches/com. apple. dyld/dyld_shared_cache_armv6 contains about 4 GB of files after decompression. Pay attention to the remaining iPhone capacity. After decompression, copy the files in the./out directory to The./toolchain/sys/usr/lib directory on linux.

Method 2
If you do not have an iPhone device, you can extract the library files from the sdk files using the following methods.

1. Download The HFSExplorer tool here. (Used in windows)

2. Use HFSExplorer to open the SDK file (. dmg file) and decompress the iPhoneSDKHeadersAndLibs. pkg file in the Packages directory to a directory. Then copy it to linux. For example, copy it to/tmp.

3. Execute the following command to pressurize the data packet:

$ Cd/tmp
$ Xar-xf iPhoneSDKHeadersAndLibs. pkg Payload
$ Zcat Payload | cpio-I

After that, several subdirectories will be generated under the/tmp directory. What we need here is the stuff under the Platforms directory. Copy the./Platforms/iPhoneOS. platform/Developer/SDKs/iPhoneOS3.1.2.sdk directory and Its subdirectory to the sdks directory of toolchain.

1 $ cp-rp./Platforms/iPhoneOS. platform/Developer/SDKs/iPhoneOS3.1.2.sdk/home/xxx/toolchain/sdks/

Note that the toolchain/sdks/directory already contains the iPhoneOS3.1.2.sdk Directory, which is completely overwritten. After the above modification, the SDK path in the makefile just now needs to be modified, as shown below.

# IPhone SDK path
IPHONESDK =/home/xxx/toolchain/sdks/iPhoneOS3.1.2.sdk
...

--------------------------------------------------------------------------------
Next, you can compile your own program and test it on the machine. Don't forget to sign with ldid !. For example, HelloToolchain is:

1 ldid-S HelloToolchain _


Toolchain for iPhone SDK 3.1.2

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.