3
我正在尝试使用Emscripten编译一些用C语言编写的R函数。我的第一个任务是移植一个名为pf
的函数。使用Emscripten将R函数编译为JavaScript
来源可以找到here。所以,我进入src目录并尝试运行:
(trunk)⚡ % emcc -s EXPORTED_FUNCTIONS="['_Rf_pf']" nmath/pf.c
warning: unresolved symbol: Rf_pbeta
warning: unresolved symbol: Rf_pchisq
warning: unresolved symbol: R_NaN
warning: unresolved symbol: R_NegInf
warning: unresolved symbol: R_PosInf
我在输出的JavaScript得到一个功能_Rf_pf
。我实际上可以调用这个函数并返回一个结果。但是,因为R_PosInf
和公司没有解决,它在R_P_bounds_01(x, 0., ML_POSINF);
短路。 ML_POSINF
以某种方式设置为0给出奇怪的结果。所以算法的核心不会被执行。
有谁知道我如何才能解决这些符号并获得此函数移植?
我可以尝试编译多个源,这似乎让我的地方:
$ emcc -s EXPORTED_FUNCTIONS="['_Rf_pf']" nmath/pf.c nmath/pbeta.c nmath/pchisq.c
warning: unresolved symbol: R_finite
warning: unresolved symbol: Rf_pgamma
warning: unresolved symbol: Rf_warning
warning: unresolved symbol: bratio
warning: unresolved symbol: gettext
warning: unresolved symbol: R_NaN
warning: unresolved symbol: R_NegInf
warning: unresolved symbol: R_PosInf
但是,这似乎导致我下一个巨大的兔子洞。然后,我碰到一些障碍:
$ emcc -s EXPORTED_FUNCTIONS="['_Rf_pf']" nmath/pf.c nmath/pbeta.c nmath/pchisq.c main/arithmetic.c
In file included from main/arithmetic.c:35:
include/Defn.h:201:3: error: SIZE_MAX is required for C99
# error SIZE_MAX is required for C99
^
include/Defn.h:639:9: error: unknown type name 'R_size_t'
extern0 R_size_t R_NSize INI_as(R_NSIZE);/* Size of cons cell heap */
^
include/Defn.h:640:9: error: unknown type name 'R_size_t'
extern0 R_size_t R_VSize INI_as(R_VSIZE);/* Size of the vector heap */
^
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
请注意,我有CPATH设置。我不知道这是否是去指点一下编译器不同的头,我需要的方式:
(trunk)⚡ % echo $CPATH
gnuwin32/fixed/h/:/usr/local/Cellar/r/3.1.2_1/include/:/usr/local/Cellar/r/3.1.2_1/R.framework/Versions/3.1/Resources/include/:nmath/:include/:main/:include/R_ext
谢谢,很好的信息。但是,这并没有多大帮助。我从运行'。/ configure'得到了一个非windows config.h,并且现在使用-DHAVE_CONFIG_H来包含它,但问题依然存在。 – 2015-02-23 02:26:46