我想知道如何在Emscripten中使用FS
。我想我已经完成了维基中提到的所有事情,但我仍然得到Uncaught ReferenceError: FS is not defined
。如果我搜索结果* .js文件的文字FS
没有发生,我认为应该有。Emscripten使用Filesystem FS
这是我到目前为止的代码。
InfoMedia.cpp
#include <math.h> //testing include
extern "C" {
// testing function
int int_sqrt(int x) {
return sqrt(x);
}
}// extern c
init_fs.js与
emcc -s EXPORTED_FUNCTIONS="['_int_sqrt']" InfoMedia.cpp -o InfoMedia.js
结果编译
var Module = {
'print': function(text){
console.log(text)
},
'preRun' : function(){
console.log('prerun');
FS.createPath('/', 'home/user1', true, true);
},
'noInitialRun': true,
};
个excample.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>InfoMediaJS-Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"> </script>
<script type="text/javascript" src="init_fs.js"></script>
<script type="text/javascript" src="InfoMedia.js"></script>
<script type="text/javascript">
run();
</script>
</head>
<body></body>
</html>
铬预试运行此之后被调用,我得到的错误。
prerun init_fs.js:6
Uncaught ReferenceError: FS is not defined init_fs.js:7
另外,如果我尝试嵌入在编译时一个文件
emcc -s EXPORTED_FUNCTIONS="['_int_sqrt']" --embed-file gizmo.webm InfoMedia.cpp -o InfoMedia.js
我得到这个错误Uncaught TypeError: Object #<Object> has no method 'FS_createDataFile'
这是我生成的js文件里面在该行http://pastebin.com/Mu1qfG25 @ line 1460 Module['FS_createDataFile']('/', 'gizmo.webm', [26, 69, 223,....]), true, true);
FS is n永远插入到生成的js文件中。所以无论我怎么称那个FS东西都没关系。有没有我需要添加的编译器选项来插入图书馆的功能?