emscripten:"要求导出的功能,但未实现"

时间:2015-02-15 04:12:34

标签: javascript c r emscripten

R中有一个名为pf的函数,来源为here

我试图通过emscripten将此功能转换为JavaScript。我这样调用:

emcc -s EXPORTED_FUNCTIONS="['pf']" nmath/pf.c \
-Ignuwin32/fixed/h/ \
-I/usr/local/Cellar/r/3.1.1/include/ \
-I/usr/local/Cellar/r/3.1.1/R.framework/Versions/3.1/Resources/include/

我收到警告:

WARNING  root: function requested to be exported, but not implemented: "pf"

并且输出js中没有pf的提示。为什么这个功能"没有实现"根据emcc?

编辑(根据zakki的答案,它应该是_pf -s EXPORTED_FUNCTIONS="['_pf']",但问题仍然存在):

有关于绝对包含路径的事先警告。但是,我假设可以忽略它?也许它至关重要:

emcc -s EXPORTED_FUNCTIONS="['_pf']" nmath/pf.c -Ignuwin32/fixed/h/ -I/usr/local/Cellar/r/3.1.1/include/ -I/usr/local/Cellar/r/3.1.1/R.framework/Versions/3.1/Resources/include/

WARNING  root: -I or -L of an absolute path "-I/usr/local/Cellar/r/3.1.1/include/" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass '-Wno-warn-absolute-paths' to emcc to hide this warning.
WARNING  root: function requested to be exported, but not implemented: "_pf"

如果我尝试其他方法,按照here所述添加EMSCRIPTEN_KEEPALIVE,我会得到:

emcc nmath/pf.c -Ignuwin32/fixed/h/ -I/usr/local/Cellar/r/3.1.1/include/ -I/usr/local/Cellar/r/3.1.1/R.framework/Versions/3.1/Resources/include/  

WARNING  root: -I or -L of an absolute path "-I/usr/local/Cellar/r/3.1.1/include/" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass '-Wno-warn-absolute-paths' to emcc to hide this warning.
nmath/pf.c:28:28: error: expected ';' after top level declarator
double EMSCRIPTEN_KEEPALIVE pf(double x, double df1, double df2, int lower_tail, int log_p)
                           ^
                           ;
1 error generated.
ERROR    root: compiler frontend failed to generate LLVM bitcode, halting

1 个答案:

答案 0 :(得分:5)

添加' _'功能名称。

-s EXPORTED_FUNCTIONS="['_pf']"