如何从源代码将Node.js构建为共享库 [英] How to build nodejs as a shared library from source code

查看:93
本文介绍了如何从源代码将Node.js构建为共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的c ++项目中包含 node.h ,我试图使用以下代码从源代码构建节点:

  ./配置须藤制作 

我有一个节点可执行文件,还有一些目标文件和.a文件,我需要构建为.so文件才能在我的c ++代码中使用它.

我尝试构建 libnode ,但是出现cmakelists错误,这不是正式的nodejs项目./p>

如果有人知道如何从源代码中以.so文件形式构建Node.js会很棒,那么 Google网上论坛中的类似问题,但答案无效.

解决方案

已将对构建为共享库的支持添加到节点主线中.请参阅 PR 6994 ,尤其是该libnode, but I got cmakelists error and this is not official nodejs project.

if anybody know how to build nodejs from source code as .so file will be great, a similar question in a google group but the answer is not working.

解决方案

Support for building as a shared library has been added in to node mainline. Please see PR 6994 and specifically this comment.

I just ran

git clone https://github.com/nodejs/node.git
cd node
git checkout v6.9.4
./configure --shared
make -j4

which produced:

ubuntu@server:~/node$ find . -name libnode.so\* -exec ls -la {} \;
-rwxrwxr-x 2 ubuntu ubuntu 31576776 Jan  6 18:57 ./out/Release/lib.target/libnode.so.48
-rw-rw-r-- 1 ubuntu ubuntu 387 Jan  6 18:57 ./out/Release/.deps/home/ubuntu/node/out/Release/lib.target/libnode.so.48.d
-rw-rw-r-- 1 ubuntu ubuntu 4202 Jan  6 18:57 ./out/Release/.deps/home/ubuntu/node/out/Release/obj.target/libnode.so.48.d
-rwxrwxr-x 2 ubuntu ubuntu 31576776 Jan  6 18:57 ./out/Release/obj.target/libnode.so.48
ubuntu@server:~/node$ 

这篇关于如何从源代码将Node.js构建为共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆