`
luckliu521
  • 浏览: 253187 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

xcode 编译静态库

 
阅读更多
这里以libcurl 为例:

      1.首先需要下载 libcurl  http://curl.haxx.se/download.html .解压...

      2.打开mac上的 terminal :切换到 解压的libcurl 的目录下...

     3.编译配置:

   export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1

      export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
      export LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -Wl,-syslibroot            /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
       export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
     ./configure --disable-shared --without-ssl --without-libssh2 --without-ca-bundle --without-ldap --disable-ldap --host=arm-apple-darwin10

    以上export的版本为本机安装的 xcode sdk版本 和 gcc版本....使用时 改为自己机子安装的...  路径也可能需要变...

    通过cd 到以上路径 能找到内容,即可。

    配置结束后 可以看到 :Protoclols:  ............TELNET TFTP

  4. 编译libcurl

     (1)  打开Xcode选择: File->New Project->iOS->Library->Cocoa Touch Static Library

      添加文件:Add->Existing Files (选择curl中 "src"文件夹),Add->Existing Files (选择curl中 "lib"文件夹)
    
     (2)选中工程,打开“build”选项,查找Oher_c_flags 设置下面信息
         -DHAVE_CONFIG_H -I/ca/dev/code/lib/curl/curl-latest/include -I/ca/dev/code/lib/curl/curl-latest/lib

       注: /ca/dev/code/lib/curl/curl-latest就是刚才解压curl源代码的路径,在本机中是 -DHAVE_CONFIG_H -I/Users/rosa/curl-7.21.7/include -I/Users/rosa/curl-7.21.7/lib

5. 利用 lipo 制作通用版本 静态库
  
      由于libcurl在device和simulator上要选择不同的版本,因此在实际使用的时候切换起来很不方便,可以在终端上使用mac os 自带的lipo工具制作为通用版本,通用版本的大小其实就是两个版本加起来的和。命令行如下:
lipo -create  /b-debug/libcurl.a /a-debug/libcurl.a -output libcurl-debug.a
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics