iOS 中的 Gnu 科学库

发布于 2024-11-25 15:48:09 字数 298 浏览 8 评论 0原文

如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暗藏城府 2024-12-02 15:48:09

好的!对我有用的配置:

sudo ./configure --disable-shared --disable-dependency-tracking
--host=armv7-apple-darwin10 CFLAGS="-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/include
-I/Library/iPhone/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
CC =“/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1”
CPP=cpp LDFLAGS="-isysroot
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"

Ok! The configuration that worked for me:

sudo ./configure --disable-shared --disable-dependency-tracking
--host=armv7-apple-darwin10 CFLAGS="-I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/include
-I/Library/iPhone/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"
CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1"
CPP=cpp LDFLAGS="-isysroot
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk"

Hello爱情风 2024-12-02 15:48:09

运行 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.

漆黑的白昼 2024-12-02 15:48:09

这并不容易,但这些是我让它工作的步骤...

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() ,当我跟踪所有方法调用时,这是所需的所有函数的列表。 (任何后面带有 * 的函数都是已经遇到过的函数,因此我不需要追踪它):

gsl_cdf_tdist_P
    cornish_fisher
        poly_eval
    gsl_cdf_ugaussian_P
        gauss_small
        gauss_medium
            get_del
        gauss_large
            get_del*
    beta_inc_AXPY
        gsl_sf_gamma_inc_Q
            gsl_sf_gamma_inc_Q_e
                gamma_inc_P_series
                    gamma_inc_D
                        gsl_sf_lngamma_e
                            lngamma_1_pade
                            lngamma_2_pade
                            lngamma_lanczos
                            lngamma_sgn_0
                            lngamma_sgn_sing
                                gsl_sf_lnfact_e
                                    gsl_sf_lngamma_e*
                                gsl_sf_psi_int_e
                                gsl_sf_psi_1_int_e
                                gsl_sf_psi_n_e
                                    gsl_sf_psi_e
                                        psi_x
                                            cheb_eval_e*
                                    gsl_sf_psi_1_e
                                        psi_n_xg0
                                            gsl_sf_psi_e*
                                            gsl_sf_hzeta_e
                                            gsl_sf_lnfact_e*
                                            gsl_sf_exp_mult_err_e
                                    gsl_sf_hzeta_e*
                                    gsl_sf_lnfact_e*
                                    gsl_sf_exp_mult_err_e*
                            lngamma_lanczos*
                        gsl_sf_gammastar_e
                            gsl_sf_lngamma_e*
                            gsl_sf_exp_err_e
                            cheb_eval_e*
                            gammastar_ser
                    gsl_sf_exprel_n_CF_e
                        exprel_n_CF
                gamma_inc_Q_asymp_unif
                    gsl_sf_log_1plusx_mx_e
                        cheb_eval_e*
                    gsl_sf_erfc_e
                        cheb_eval_e*
                gamma_inc_Q_series
                gamma_inc_Q_CF
                    gamma_inc_D*
                    gamma_inc_F_CF
                        gsl_pow_3
                    gamma_inc_Q_large_x
                        gamma_inc_D*
                    gamma_inc_Q_CF*
                    gamma_inc_P_series*
        gsl_sf_gamma_inc_P
            gsl_sf_gamma_inc_P_e
                gamma_inc_P_series*
                gamma_inc_Q_asymp_unif*
                gamma_inc_Q_CF*
                gamma_inc_Q_large_x*
                gamma_inc_P_series*
        gsl_sf_lnbeta
            gsl_sf_lnbeta_e
                gsl_sf_lnbeta_sgn_e
                    isnegint
                    gsl_sf_gammastar_e*
                    gsl_sf_log_1plusx_e
                        cheb_eval_e*
                    gsl_sf_lngamma_sgn_e
                        lngamma_1_pade*
                        lngamma_2_pade*
                        lngamma_lanczos*
                        lngamma_sgn_0*
                        lngamma_sgn_sing*
        beta_cont_frac

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 #includes 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):

gsl_cdf_tdist_P
    cornish_fisher
        poly_eval
    gsl_cdf_ugaussian_P
        gauss_small
        gauss_medium
            get_del
        gauss_large
            get_del*
    beta_inc_AXPY
        gsl_sf_gamma_inc_Q
            gsl_sf_gamma_inc_Q_e
                gamma_inc_P_series
                    gamma_inc_D
                        gsl_sf_lngamma_e
                            lngamma_1_pade
                            lngamma_2_pade
                            lngamma_lanczos
                            lngamma_sgn_0
                            lngamma_sgn_sing
                                gsl_sf_lnfact_e
                                    gsl_sf_lngamma_e*
                                gsl_sf_psi_int_e
                                gsl_sf_psi_1_int_e
                                gsl_sf_psi_n_e
                                    gsl_sf_psi_e
                                        psi_x
                                            cheb_eval_e*
                                    gsl_sf_psi_1_e
                                        psi_n_xg0
                                            gsl_sf_psi_e*
                                            gsl_sf_hzeta_e
                                            gsl_sf_lnfact_e*
                                            gsl_sf_exp_mult_err_e
                                    gsl_sf_hzeta_e*
                                    gsl_sf_lnfact_e*
                                    gsl_sf_exp_mult_err_e*
                            lngamma_lanczos*
                        gsl_sf_gammastar_e
                            gsl_sf_lngamma_e*
                            gsl_sf_exp_err_e
                            cheb_eval_e*
                            gammastar_ser
                    gsl_sf_exprel_n_CF_e
                        exprel_n_CF
                gamma_inc_Q_asymp_unif
                    gsl_sf_log_1plusx_mx_e
                        cheb_eval_e*
                    gsl_sf_erfc_e
                        cheb_eval_e*
                gamma_inc_Q_series
                gamma_inc_Q_CF
                    gamma_inc_D*
                    gamma_inc_F_CF
                        gsl_pow_3
                    gamma_inc_Q_large_x
                        gamma_inc_D*
                    gamma_inc_Q_CF*
                    gamma_inc_P_series*
        gsl_sf_gamma_inc_P
            gsl_sf_gamma_inc_P_e
                gamma_inc_P_series*
                gamma_inc_Q_asymp_unif*
                gamma_inc_Q_CF*
                gamma_inc_Q_large_x*
                gamma_inc_P_series*
        gsl_sf_lnbeta
            gsl_sf_lnbeta_e
                gsl_sf_lnbeta_sgn_e
                    isnegint
                    gsl_sf_gammastar_e*
                    gsl_sf_log_1plusx_e
                        cheb_eval_e*
                    gsl_sf_lngamma_sgn_e
                        lngamma_1_pade*
                        lngamma_2_pade*
                        lngamma_lanczos*
                        lngamma_sgn_0*
                        lngamma_sgn_sing*
        beta_cont_frac
雨巷深深 2024-12-02 15:48:09

我不确定是否有更好的方法,但这就是我所做的:
我在 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文