构建没有node-waf的node.js插件
我正在使用 Eclipse CDT 用 C++ 编写一个简单的 node.js 插件。该项目有很多文件,我想使用 Eclipse 的托管构建系统。
我可以使用 node-waf
编译一个简单的插件示例,但我无法配置我的 Eclipse 工具链来构建没有 waf 的正确共享库。 Waf 在幕后使用 gcc,所以我确信这是可能的。
我应该链接到哪些库以及应该传递什么样的选项才能使其正常工作?
目前,如果我尝试 require
我的库,则会收到以下错误:
SyntaxError: Unexpected token ILLEGAL
I'm writing a simple node.js addon in C++ using Eclipse CDT. The project has many files and I'd like to use the Eclipse's managed build system.
I can compile a simple addon example with node-waf
, but I can't configure my Eclipse toolchain to build a proper shared library without waf. Waf uses gcc behind the scenes, so I'm sure it's possible.
Which libs should I link to and what kind of options should I pass along to make it work?
Currently I get the following error if I try to require
my lib:
SyntaxError: Unexpected token ILLEGAL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
终于找到了答案。
所需的编译器标志:
链接器标志:
导入说明:
共享库必须具有扩展名
.node
,例如:foobar.nodeFinally found the answer.
Required compiler flags:
Linker flags:
Importand note:
The shared library must have the extension
.node
, e.g: foobar.node我还没有在 Linux 中尝试过,但至少在 OSX 中我必须使用
-undefine subsup
和-flat_namespace
因为 node.js(v0.4.12) 有它自己的静态链接可执行文件中的 v8 库。下面的 Makefile 在 MacOSX Lion 中将 mod.cpp 编译为 mod.node:
$ file mod.o
$ file mod.node
运行 make:
注意: mod 的源代码。它来自 插件教程
I haven't tried in Linux but at least in OSX I had to use
-undefined suppress
and-flat_namespace
since node.js(v0.4.12) has it's own statically linked v8 library in the executable.The following Makefile compiles mod.cpp into mod.node in MacOSX Lion:
$ file mod.o
$ file mod.node
Running make:
Note: The source code of mod.cpp it's from the Addons tutorial