我想知道如何在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東西都沒關係。有沒有我需要添加的編譯器選項來插入圖書館的功能?