iOS 中的 Gnu 科学库
如何在 iOS 应用程序中使用 GNU 科学库?
我尝试按照本教程进行操作: http://www.os-scientific.org/devel /gslxcode/index.html。但这种方式似乎不适用于 iOS,仅适用于 OS X。在我使用“外部构建系统”将 GSL 源代码添加到 XCode 后,XCode 希望为 OS X SDK 构建该 GSL 子项目的目标,而不是iOS SDK。
How can I use the GNU Scientific Library in an iOS application?
I tried following this tutorial: http://www.os-scientific.org/devel/gslxcode/index.html. But it seems not to work for iOS this way, only for OS X. After I added the GSL source code to XCode using an "external build system", XCode wants to build the target of that GSL subproject for the OS X SDK instead of the iOS SDK.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好的!对我有用的配置:
Ok! The configuration that worked for me:
运行 iOS 的小型设备是 32 位系统。您需要通过如下配置 make 过程来重建 32 位计算机的 Gnu Science Library (GSL):./configure CFLAGS="-arch i386",然后根据以下内容 make 并将新库文件链接到您的项目第一次尝试时的教程。
上述声明的修订版:该建议对于获得适用于 iOS 模拟器的构建效果很好,但尚不清楚是否可以在不更改代码库的情况下成功为 ARMv7 架构构建 GSL。如果可能的话,似乎需要一种与所提供的工具链不同的工具链来构建 GSL。
Small devices running iOS are 32-bit systems. You will need to rebuild the Gnu Science Library (GSL) for 32-bit machines by configuring the make process as follows: ./configure CFLAGS="-arch i386", then make and link the new library file to your project according to the tutorial in your first attempt.
A revision of the above statement: That advice works fine in getting a build that works for the iOS simulator, but it's not clear that GSL can even be successfully built for the ARMv7 architecture without changing the code base. If it is at all possible, it would appear that one needs a different tool chain for building GSL from the one provided.
这并不容易,但这些是我让它工作的步骤...
1) 下载并解压最新的 GSL
2) 在 gsl 目录中,
./configure
--disable-shared --disable-dependency-tracking CFLAGS="-DGSL_C99_INLINE -g -O2"
3) 在 Xcode 中创建一个 Cocoa Touch 静态库项目。
4) 将以下标头复制到项目中:
config.h、build.h、gsl_machine.h
5) 找到您要在项目中使用的函数。将这些
.c
文件复制到您的项目中。6) 然后跟踪该函数以查看它调用了哪些其他函数,一直到底部。
7) 将这些函数所在的所有
.c
文件复制到您的项目中。8) 将这些函数定义所需的所有
.h
文件复制到您的项目中。9) 有一种更优雅的方法来做到这一点,但对我来说,我只是采取了简单的路线,并将
#include
语句更改为#include " xxxxxx.h”
。注释掉任何您实际上不需要的#include
。10) 这些
.c
文件中不需要的任何函数,您可以将其删除,以减少需要使用的其他包含的数量。您可以直接删除它们,但我建议将#if 0
和#endif
放在它们周围。以防万一您错过了某些内容并需要稍后添加它们。11) 构建并检查错误。如果您缺少某个函数,请包含该函数的
.c
文件,然后冲洗,重复。我需要为我的项目包含
gsl_cdf_tdist_P()
,当我跟踪所有方法调用时,这是所需的所有函数的列表。 (任何后面带有 * 的函数都是已经遇到过的函数,因此我不需要追踪它):It wasn't easy, but these are the steps I took to get it working...
1) Download and extract latest GSL
2) In the gsl directory,
./configure
--disable-shared --disable-dependency-tracking CFLAGS="-DGSL_C99_INLINE -g -O2"
3) Create a Cocoa Touch Static Library project in Xcode.
4) Copy the following headers into the project:
config.h, build.h, gsl_machine.h
5) Find the function(s) you want to use in your project. Copy those
.c
files into your project.6) Then track through that function to see what other functions it calls, all the way down to the bottom.
7) Copy into your project all of the
.c
files those functions are in.8) Copy into your project all of the
.h
files needed for those function definitions.9) There is a more elegant way to do this, but for me, I just took the simple route and changed the
#include <gsl/xxxxx.h>
statements to#include "xxxxxx.h"
. Comment out any#include
s that you don't actually need.10) Any function you don't need in those
.c
files, you can remove them in order to reduce the number of other includes you need to use. You can either just delete them, but I recommend putting#if 0
and#endif
around them instead. Just in case you missed something and need to include them later.11) Build and check for errors. If you're missing a function, include the
.c
file for that function, rinse, repeat.I needed to include
gsl_cdf_tdist_P()
for my project, and when I tracked down through all of the method calls, this is the list of all of the functions needed. (any function with an * after is one that has already been encountered, so I didn't need to track down through it):我不确定是否有更好的方法,但这就是我所做的:
我在 XCode 上创建了一个新的“Cocoa Touch Static Library”项目,并放入了我需要的所有必要的 GSL 源文件。如果你想在iPhone上运行它,请将活动方案设置为“iOS设备”(否则,它只能在iPhone模拟器上运行)。然后构建项目,您将获得可在 iPhone 上运行的静态 GSL 库!
I'm not sure if there is a better way but here is what I do:
I created a new "Cocoa Touch Static Library" project on XCode and put in all the necessary GSL source files I needed. Set the active scheme to "iOS device" if you want to run it on iPhone (otherwise, it will only work on iPhone simulator). Then build the project and you'll get your static GSL library that works on iPhone!