TooTallNate/node-gyp — Issue #27: Windows can't build Hello World example
Author: arturadib
Created: 2012-02-25 17:09:43+00:00
State: open

Using MSVC++ Express on Windows 7, Python 2.7, node-gyp v0.1.3 (via npm -g).

Problem happens when trying to build a fresh copy of the [Hello World addon](https://github.com/joyent/node/tree/master/test/addons/hello-world) from the Node-Gyp page.

The same Hello World example works out-of-the-box on OS X.

# Problem #1

At first node-gyp seems to look for a `bindings.gyp` file rather than `binding.gyp`:

```
Z:\projs\node\gyp-hello-world\binding>node-gyp configure
info it worked if it ends with ok
info downloading: http://nodejs.org/dist/v0.6.0/node-v0.6.0.tar.gz
info downloading `node.lib` http://nodejs.org/dist/v0.6.10/node.lib
spawn python [ '.node-gyp\\0.6\\tools\\gyp_addon',
'-Dnode_root_dir=.node-gyp\\0.6',
'-I',
'.node-gyp\\0.6\\tools\\patch.gypi',
'-Dtarget_arch=ia32' ]
info done ok

Z:\projs\node\gyp-hello-world\binding>node-gyp build
info it worked if it ends with ok
spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe [ 'bindings.sln'
,
'/clp:Verbosity=minimal',
'/nologo',
'/p:Configuration=Release' ]
MSBUILD : error MSB1009: Project file does not exist.
Switch: bindings.sln
ERR! Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed w
ith exit code: 1
at Array.1 (C:\Users\Artur Adib\AppData\Roaming\npm\node_modules\node-gyp\li
b\build.js:118:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
```

# Problem #2

If I rename `binding.gyp` to `bindings.gyp` then it seems to build OK, except for a warning message concerning a mismatch of extensions (`.dll` vs `.node`):

```
Z:\projs\node\gyp-hello-world\bindings>node-gyp build
info it worked if it ends with ok
spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe [ 'bindings.sln'
,
'/clp:Verbosity=minimal',
'/nologo',
'/p:Configuration=Release' ]
binding.cc
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990
,5): warning MSB8012: TargetPath(Z:\projs\node\gyp-hello-world\bindings\Release\
binding.dll) does not match the Linker's OutputFile property value (Z:\projs\nod
e\gyp-hello-world\bindings\Release\binding.node). This may cause your project to
build incorrectly. To correct this, please make sure that $(OutDir), $(TargetNa
me) and $(TargetExt) property values match the value specified in %(Link.OutputF
ile). [Z:\projs\node\gyp-hello-world\bindings\binding.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991
,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile pro
perty value (.node). This may cause your project to build incorrectly. To correc
t this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property
values match the value specified in %(Link.OutputFile). [Z:\projs\node\gyp-hell
o-world\bindings\binding.vcxproj]
Creating library Z:\projs\node\gyp-hello-world\bindings\Release\binding.lib
and object Z:\projs\node\gyp-hello-world\bindings\Release\binding.exp
Generating code
Finished generating code
binding.vcxproj -> Z:\projs\node\gyp-hello-world\bindings\Release\binding.dll
info done ok
```

# Problem #3

Since the build was seemingly OK, I tried to run `test.js`, but it complains that there is no binary in `./out/Release/binding`. Instead, the binary was produced in `./Release/binding`.

# Problem #4

Fixing the path issue above and running `test.js` again now leads to the following error:

```
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: unknown error
at Object..node (module.js:472:11)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (Z:\projs\node\gyp-hello-world\bindings\test.js:2:15)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
```

I assume this is related to problem #3 (.dll vs .node)?

Anyway, any help here is much appreciated.

Thanks Nate, for the superb tool.