Home  >  Q&A  >  body text

nw.js 制作ide的问题

学校的课程设计中要制作一个ide用来编辑c/c++,有一个功能是编译,就是我点一下就弹出控制台显示编译的结果,请问node有调用c++编译的接口吗,怎么实现这个功能?

高洛峰高洛峰2873 days ago557

reply all(1)I'll reply

  • 三叔

    三叔2016-11-09 10:44:48

    你可能需要的是这个。https://nodejs.org/api/child_process.html

    const exec = require('child_process').exec;
    let server = exec('g++ -o hello hello.cpp', function(err, stdout, stderr) {
      if (err) console.error(stderr);
      console.log(stdout);
    });
    server.stdout.on('data', function(data) {
      console.log(data);
    });
    // process.on('exit', function() { 
    //   server.kill();
    // });


    reply
    0
  • Cancelreply