将FreeTDS交叉编译到iPhone [英] Cross compiling FreeTDS to iPhone

查看:197
本文介绍了将FreeTDS交叉编译到iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这个问题没有答案,我花了大部分时间来计算它,我想我会发布如何将FreeTDS 0.91交叉编译为iPhone ARMv6,ARMv7架构。这是使用Xcode 4.2和iOS 5 SDK完成的。

Since this question is unanswered and I spent the majority of a semester figuring it I thought I would post how to Cross compiling FreeTDS 0.91 to iPhone ARMv6, ARMv7 architecture. This was done using Xcode 4.2 and iOS 5 SDK.

之所以提出这个问题,是因为您正在为需要连接到Mircosoft SQL的iOS设备开发应用程序Sever,需要使用Tabular Data Stream(TDS)协议,因为它是Microsoft专有的。

The reason this question is asked it because you are developing an app for an iOS device that requires connecting to an Mircosoft SQL Sever, which requires using the Tabular Data Stream (TDS) protocol as it is Microsoft proprietary.

我还要提到你需要一定程度的技术才能尝试这个。这是我花了将近两个月才弄明白的一个非常简洁的版本(我留下了你不应该做的所有事情)。

I will also mention that you need some level of technical skill to even attempt this. This is a very condensed version of what took me nearly two months to figure out (I left all the things you shouldn't do).

与此有关的其他文件:

Other documentation relating to this:

基本如何使用FreeTDS http: //www.freetds.org/userguide/samplecode.htm

Basic How To on using FreeTDS http://www.freetds.org/userguide/samplecode.htm

Microsoft的TDS API文档
http://msdn.microsoft.com/en-us/library/aa936985(v = sql.80)

Microsoft's TDS API documentation http://msdn.microsoft.com/en-us/library/aa936985(v=sql.80)

请参阅下面的答案。

另请参阅saskathex回答Xcode 4.5更新文件。

Also see saskathex answer for Xcode 4.5 updated files.

推荐答案

对于像我这样花时间查找这些标准配置标志文档的人(用于运行./configure make make install)

For those like me that will spend hours finding the documentation for these standard configure flags (for running ./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/

1) Get the latest version of the FreeTDS http://www.freetds.org/

2)下一步是制作正确运行FreeTDS ./configure的自己的bash shell文件。你需要两个,因为模拟器是i386 / i686架构,苹果设备(iPhone,iPod等)是ARM架构。此外,iPhone开发目录中的编译器文件/版本可能不同,只需查找具有逻辑意义且具有类似命名约定的内容。 mac主机体系结构随命令uname -p一起提供。

2) The next step is to make your own bash shell files that correctly run the FreeTDS ./configure. You will need two as the simulator is i386/i686 architecture and an apple device (iPhone, iPod, etc.) is ARM architecture. Also, your compiler files/version within the iPhone development directories may be different, just find what makes logical sense and has similar naming convention. The mac host architecture is supplied with the command uname -p.

这是我在模拟器上构建的示例(i386)build_for_simulator_i386.sh:

Here is my example for building for use on the simulator (i386) build_for_simulator_i386.sh:

 #!/bin/sh

 #unset some shell variables
 unset CC
 unset CFLAGS
 unset CPP

 export buildPath=`pwd`

 # make i386 (Simulator) target
 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"

 # if you want Windows Authentication (NTLM) support you must use at least tds version 7
 # the default is 5
 ./configure --build=i386 --host=i386 --target=i386 --with-tdsver=7.1 

配置ARM的示例编译(build_for_device_armv7.sh):

Example for configuring for ARM compilation (build_for_device_armv7.sh):

 #!/bin/sh

 # unset some shell variables
 unset CC
 unset CFLAGS
 unset CPP

 export buildPath=`pwd`

 # make arm target
 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目录,我的是freetds_0.91

3) Next cd to the root freetds directory that resulted from unzipping the freetds download, mine was freetds_0.91

4)运行你的一个脚本。您一次只能编译 ONE 架构

4) Run one of your scripts. You can only compile for ONE architecture at a time

 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

5) Once the configure process completes you have to hack the configuration file. Open freetds_0.91/include/config.h then on line 172 change #define HAVE_ICONV 1 to #define HAVE_ICONV 0

6)如果您之前运行过./configure,make,make install,则运行这些命令。特别是如果您的交换架构因为您将在运行时出错而无需执行此操作

6) If you previously ran ./configure, make, make install then run these commands. Especially if your switching architectures as you will get errors running make without doing this

    sudo make clean
    sudo make uninstall

7)使用make

    make all
    sudo make install

制作程序通过一些有意的错误来做,但如果你看到shell或提示符的六到七行内的错误,一旦它返回,你就会遇到问题并需要在继续之前修复它们。让我们说很多事情在这一点上可能会出错。

The make procedure does through some error on purpose, but if you see errors within six or seven lines of shell prompt, once it returns, you have problems and need to fix them before proceeding. Lets just say lots of things can go wrong at this point.

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。

8) After installing the binary complied file that is the culmination of all the little .o files that freetds makes is /usr/local/lib/libsybdb.a Trust me you don't want to pull a .o file for just the library you want. Copy /usr/local/lib/libsybdb.a to the appropriate folder in your project. What I did was have two separate folders, one per architecture, named "compiled_freetds-0.91_simulator_i386" and "compiled_freetds-0.91_device_armv7."

9)因为你想让你的生活变得轻松,并让xcode弄清楚要使用哪个编译文件,请按照这个步骤子集来执行动态链接。

9) Since you want to make you life easy and have xcode figure out which compiled file to use follow this subset of steps to perform the dynamic linking.

 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被弃用,这是正常的,但是很烦人。

10) The final step which seems to avoid problem of dynamic linking error involving libsybdb.5.dylib when running code on device is to make uninstall. Also, when running on the device you will also get lots of warnings, in increments of 36, about CPU_SUBTYPE_ARM_ALL being deprecated, that is normal, but annoying.

    sudo make uninstall  

我希望这会有所帮助。

这篇关于将FreeTDS交叉编译到iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆