无法为iOS模拟器构建OpenSSL

时间:2016-01-14 03:53:50

标签: ios openssl

我尝试使用以下步骤为iOS模拟器构建OpenSSL: (MackBook Pro,OS X版本10.10.5v + Xcode版本7.2)

$ mkdir openssl
$ cd openssl
$ wget http://www.openssl.org/source/openssl-1.0.2e.tar.gz
$ tar xvzf openssl-1.0.2e.tar.gz
$ cd openssl-1.0.2e
$ mkdir /tmp/openssl-1.0.2e-i386
$ ./configure BSD-generic32 --openssldir=/tmp/openssl-1.0.2e-i386
$ vi Makefile
  Make the following changes:
  1) Replace
      "CC= gcc"
       with
      "CC= /Applications/Xcode.app/Contents/Developer/usr/bin/gcc -arch i386"
  2) Append
      "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
      to the end of
      "CFLAG= ..."
$ make

但是,会发生以下错误:

ld: building for OSX, but linking against dylib built for iOS, file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/libSystem.dylib' for architecture i386

有人可以告诉我出了什么问题吗?

2 个答案:

答案 0 :(得分:0)

错误是您在导入并尝试将OSX应用程序链接到iOS系统库时收到的错误。两个平台之间存在许多差异,并且库不可互换。您正在运行一行来更改为项目提取的库文件的位置。确保您指向的库包含您正在尝试构建的系统体系结构的切片(在本例中为i386)。

答案 1 :(得分:0)

通过引用other question解决了这个问题。

我在CFLAG中添加了“-miphoneos-version-min = 6.0”,问题已经消失。

感谢。