How to build C++ native module under Windows?

313 views
Skip to first unread message

Zhao Cheng

unread,
Oct 4, 2011, 12:59:30 PM10/4/11
to nodejs
On posix environments, I could use node-waf to help building modules.
But under Windows, it becomes confusing, node-waf is under the 'tools'
folder, I'm not sure whether should I manually compile and link my C++
module , or should I try to make node-waf work as in the old way? Is
there a guide on building C++ native module under Windows?

Bradley Meck

unread,
Oct 4, 2011, 1:14:47 PM10/4/11
to nod...@googlegroups.com
The Window's C++ modules need to be built in cygwin and are subject to cygwin's API. Native C++ via mingw or MSVS is in the works; I built a prototype loader, but there are some outstanding linking errors with how Windows exports DLLs (Templated class members can't export to DLL when using new Templates from the addon DLL). In order to resolve these errors a major refactor may need to occur and thus it may take some time before this is supported.

Zhao Cheng

unread,
Oct 4, 2011, 10:01:43 PM10/4/11
to nodejs
> The Window's C++ modules need to be built in cygwin and are subject to
> cygwin's API.

If I build my C++ module in cygwin, does it mean that I should
recompile
node in cygwin too?

Or can I compile my module into node? If I put my module's source
under
/src and /lib, and tweak the project configurations, will it work?

Bradley Meck

unread,
Oct 5, 2011, 8:05:21 AM10/5/11
to nod...@googlegroups.com
If you use Cygwin, everything should be built inside of Cygwin. Vice versa ( MSVS or Mingw work together but not with Cygwin ).

Eric Muyser

unread,
Oct 5, 2011, 9:35:31 PM10/5/11
to nod...@googlegroups.com
Zhao,

Yes, you must compile Node in Cygwin as well. Otherwise the binary format won't be compatible. You may be able to compile your C++ addons in Cygwin, and then create a proxy that utilizes a cygwin.dll to bind the modules, forwarding the exports. I couldn't say it would be fun, easy, or even possible, though. Yeah, that's not much help.

> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Bert Belder

unread,
Oct 5, 2011, 10:25:26 PM10/5/11
to nodejs
On Oct 5, 2:05 pm, Bradley Meck <bradley.m...@gmail.com> wrote:
> MSVS or Mingw work together but not with Cygwin ).

I don't think that's actually true, but we'll figure it out soon.

Bradley Meck

unread,
Oct 6, 2011, 9:35:29 AM10/6/11
to nod...@googlegroups.com
It is true but not guaranteed to be 100% (basically some complex stuff will ruin it):

RaphaelM

unread,
Oct 28, 2011, 4:28:52 AM10/28/11
to nodejs
Here you are talking about dynamic extension modules (.node)

Is it possible to build static native C++ modules under Windows,
ie add them in a (custom) node.exe build itself (src dir),
like node_buffer (Buffer), tcp_wrap?

Is there documentation / guidelines about that?

RaphaelM

unread,
Oct 28, 2011, 9:43:57 AM10/28/11
to nodejs
Here you are talking about dynamic extension modules (.node)

Is it possible to build static native C++ modules under Windows,
ie add them in a (custom) node.exe build itself (src dir),
like node_buffer (Buffer), tcp_wrap?

Is there documentation / guidelines about that?

On Oct 4, 7:14 pm, Bradley Meck <bradley.m...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages