2012-02-24 89 views
0

我跟着Writing Node.js Native Extension成功创建了helloworld.node文件。我可以成功拨打helloworld.nodeNode.js C++扩展部署

而且,我有打电话helloworld.node一个test.js。的test.js内容是

var mhw = require('./helloworld/build/Release/helloworld'); 
var hw = new mhw.HelloWorld(); 
console.log(hw.hello()); 

但我得到Unable to load shared library错误我感动helloworld.nodetest.js到另一台计算机后。

hkalex(at)shellmix ~/nodetest> node test.js 

node.js:201 
     throw e; // process.nextTick error, or 'error' event on first tick 
      ^
Error: Unable to load shared library /homex/hkalex/nodetest/helloworld/build/Release/helloworld.node 
    at Object..node (module.js:463:11) 
    at Module.load (module.js:351:31) 
    at Function._load (module.js:310:12) 
    at Module.require (module.js:357:17) 
    at require (module.js:368:17) 
    at Object.<anonymous> (/homex/hkalex/nodetest/test.js:1:73) 
    at Module._compile (module.js:432:26) 
    at Object..js (module.js:450:10) 
    at Module.load (module.js:351:31) 
    at Function._load (module.js:310:12) 
hkalex(at)shellmix ~/nodetest> 

我在开发计算机中使用root。我正在使用shellmix进行测试。

有什么想法吗?谢谢!

更新

如果我把源文件中shellmix并从源代码编译,一切都很好。

回答

1

我想在另一台机器上你没有相同的CPU架构或操作系统,并且你有机器特定的代码。通常对于节点本地模块,它们分发源代码,并在目标机器上的npm install上自动编译,以确保它在其机器上正常工作。如果使用gcc,则可以指定cpu体系结构(添加-m32或-m64)。

如果您想编译为其他操作系统,最简单的方法是在OS上编译,您也可以在虚拟机上使用virtualboxVMware player进行编译。

您也可以编译为其他操作系统比你在使用交叉编译器之一,但不推荐,因为,这将需要一些时间来建立并学会使用。说明书是herehere