对于像我这样的人,会花费数小时查找这些标准配置标志的文档(用于运行./configure make make install)。
./configure --build is used for specifing the architecture you want to complie for
./configure --host is used to specify the ark of the machine doing the compileing (running xcode)
./configure --target seems to be an alias
现在开始解决问题。
1)获取最新版本的FreeTDS:
http://www.freetds.org/
2)下一步是创建正确运行FreeTDS ./configure的自己的bash shell文件。您将需要两个,因为模拟器是i386 / i686架构,而苹果设备(iPhone、iPod等)是ARM架构。此外,您在iPhone开发目录中的编译器文件/版本可能不同,只需找到具有类似命名约定和逻辑意义的内容即可。Mac主机架构由命令uname -p提供。
以下是我用于在模拟器(i386)上构建的示例build_for_simulator_i386.sh:
unset CC
unset CFLAGS
unset CPP
export buildPath=`pwd`
export CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/i686-apple-darwin11-llvm-gcc-4.2
export CFLAGS="-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk"
./configure --build=i386 --host=i386 --target=i386 --with-tdsver=7.1
ARM编译配置示例(build_for_device_armv7.sh):
unset CC
unset CFLAGS
unset CPP
export buildPath=`pwd`
export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"
export CPP=/usr/bin/cpp
./configure --build=arm-apple-darwin10 --host=x86_64-apple-darwin11.3.0 --target=armv7 --with-tdsver=7.1
3) 接下来cd到解压freetds下载文件后得到的根目录,我的是freetds_0.91
4) 运行你的其中一个脚本。你每次只能为一个架构进行编译。
sh build_for_(desiered build)
this runs ./configure for you with the correct options
(tds version 7 required for NTLM authentication)
5) 配置过程完成后,您需要修改配置文件。打开freetds_0.91/include/config.h文件,然后在第172行将#define HAVE_ICONV 1 更改为#define HAVE_ICONV 0
6) 如果您之前运行了./configure、make、make install,则要运行这些命令。尤其是如果您要切换架构,因为如果不这样做,运行make时会出现错误。
sudo make clean
sudo make uninstall
7) 使用make进行编译
make all
sudo make install
制作过程有意引发一些错误,但如果您在 shell 提示符的六七行内看到错误,并且一旦返回,就必须解决这些问题后再继续。可以说,在这一点上会出现许多问题。
8) 安装 freetds 所编译的二进制文件时,它是所有小的 .o 文件的集大成者,位置在 /usr/local/lib/libsybdb.a,相信我,你不想只为了库文件而拉一个 .o 文件。将 /usr/local/lib/libsybdb.a 复制到项目中适当的文件夹中。我创建了两个分别命名为“compiled_freetds-0.91_simulator_i386”和“compiled_freetds-0.91_device_armv7”的文件夹,每个文件夹下有一个架构。
9) 由于您希望让 xcode 自动找到要使用的编译文件,因此请按照以下步骤进行动态链接。
a) Select you project settings on the left had side of xcode
(the blue think with the name of your project on it)
b) Select the Target (usual the same name as your app)
c) Navigate to **build settings**, scroll down to **linking > other linker flags**
d) On the left side of Other Linker Flags a mouse over will reveal an expander,
expanding will reveal Debug and Release rows.
e) Add the appriate architectures by selecting the plus on the right side of
either Debug or Release. When the new row appears select the architecture,
double click the first editable field from the right to open an entry box
that you can then drag the appropriate complied file into it to be dynamically
linked. You must do this for both files and when done correctly the file
under ARMv7 will be used when building for the device and the one for Any iOS
Simulator SDK will be used when running on the simulator.
**Note:** You may also need to add the -all_load flag to resolve linking issues.
第10步似乎可以避免在设备上运行代码时涉及libsybdb.5.dylib的动态链接错误问题,这一步是卸载。此外,在设备上运行时,您还将获得很多警告,每增加36个就会有一个,关于CPU_SUBTYPE_ARM_ALL被弃用,这是正常的,但很烦人。
sudo make uninstall
我希望这能有所帮助。