LoginSignup
5

More than 3 years have passed since last update.

posted at

updated at

Organization

emscriptenで変換してCの関数をnode.jsで使うには

背景

emscriptenでhtml出力させて、そこで使う分には問題にならないが、
node.jsでjs化したCの関数を呼び出したい時、requireではうまく行かなかった

もっとスマートな方法がいまいち分からずの投稿です。

とりあえずうごくやり方

var fs = require('fs');
eval(fs.readFileSync('hoge.js'));
// 以降、Moduleが使えるようになる
var hogeFunc = Module.cwrap('hoge', 'number', ['string']);

Link

関連投稿

関連記事

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
5