[英]Node.js C++ extension deployment
我遵循了編寫Node.js本機擴展並成功創建了helloworld.node
文件。 而且我能夠成功調用helloworld.node
。
此外,我有一個test.js
來調用helloworld.node
。 test.js
的內容是
var mhw = require('./helloworld/build/Release/helloworld');
var hw = new mhw.HelloWorld();
console.log(hw.hello());
但是,在將helloworld.node
和test.js
移至另一台計算機后,我Unable to load shared library
錯誤。
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
並從源代碼進行編譯,那么一切都很好。
我猜您在另一台機器上沒有相同的CPU體系結構或操作系統,並且您擁有機器特定的代碼。 通常對於節點本機模塊,它們分發源,並在目標計算機上的npm install上自動編譯,以確保其在其計算機上正常工作。 如果使用gcc,則可以指定cpu體系結構(添加-m32或-m64)。
如果要針對其他OS進行編譯,最簡單的方法是僅在OS上進行編譯,也可以使用virtualbox或VMware Player在虛擬機上進行編譯。
除了使用交叉編譯器之外,還可以針對其他操作系統進行編譯,但是不建議這樣做,因為這會花費一些時間來構建和學習使用。 說明在這里和這里 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.