Compile native module for atom-shell on Windows


#1

Hi,
I try to compile a native module (hello world) for atom-shell 0.16.2 on Windows 7, which uses node v0.11.13.

So I downloaded the source for node v0.11.13 to get the correct header files and compiled the module to link against node.lib. Now, when I run node.exe and put hello.node (this is my compiled module) in the same folder, I can

  • type require("./hello").hello(),
  • hit enter

and get world as output. So far so good.

But when I put the hello module in the same folder as main.js of my app running in atom-shell, an exception is raised at Module.load. What can I do about his?

Do I have to link against something else than node.lib? This is how my code looks right now (it’s just this single file):

#include <node.h>

#pragma comment(lib, "C:\\node-v0.11.13\\Release\\node")

using namespace v8;

void Method(const FunctionCallbackInfo<Value>& args) {
	Isolate* isolate = Isolate::GetCurrent();
	HandleScope scope(isolate);
	args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));
}

void init(Handle<Object> exports) {
	NODE_SET_METHOD(exports, "hello", Method);
}

NODE_MODULE(hello, init)

P.S. I just saw that there are other ways of installing native modules, but I don’t build using node-gyp and I don’t know if HOME=~/.atom-shell-gyp will work in a Windows command shell(?). Do you have any tips? I’ can’t seem to wrap my head around this.


#2

I was able to build a native module that runs in atom-shell 0.16.2 using the The node-gyp way mentioned in the link above using Cygwin under Windows!

Still, is there an equivalent of HOME=~/.atom-shell-gyp for cmd.exe? This syntax is totally new to me.

Thanks.