Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows can't build Hello World example #27

Closed
arturadib opened this issue Feb 25, 2012 · 5 comments
Closed

Windows can't build Hello World example #27

arturadib opened this issue Feb 25, 2012 · 5 comments
Labels

Comments

@arturadib
Copy link

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 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.<anonymous> (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.

@TooTallNate
Copy link
Contributor

Hey @arturadib, so except for the last one, these are more or less expected:

Problem 1

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

Yes this is actually expected, and arguably a usability bug in node-gyp. But basically the Windows target generates a <name of gyp file>.sln, whereas the Make target generates a (hard-coded predictable name) Makefile.gyp file. I've been meaning to change Windows to glob for the first .sln file in the cwd but haven't done that yet. (You can currently specify which sln to use with node-gyp build --solution=binding.sln, but ideally you don't need that).

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):

This is also expected. Node renames the resulting shared object to .node rather than .dll. MSVC decides to complain about that. Not sure if there's a way to silence that warning..

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.

Again, this is just a Windows-ism of the build system. The same thing happens when building node.exe itself! There is never an out directory, just top level Debug and Release. This also may be fixable (in the node repo), but I'm not sure really. Note that node-bindings takes care of normalizing that for you at runtime.

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

"unknown error", lovely :
I haven't actually ever seen that one yet! Are you trying out the 64-bit node.exe or something? I doubt it's related to the .dll vs .node thing. I'll fire up my Windows VM in a bit to verify that the Hello World addon builds properly...

@TooTallNate
Copy link
Contributor

So Problem #4 is fixed by nodejs/node-v0.x-archive#2828.

I'll open a new issue to glob for .sln files on Windows, so that the --solution argument is not necessary.

Closing.

@TooTallNate
Copy link
Contributor

@arturadib Check out nodejs/node-v0.x-archive#2833 which fixes Windows to build addons properly in the out dir. Cheers!

@arturadib
Copy link
Author

@TooTallNate Awesome, thanks Nate. I was actually going to ask you about those random files scattered around root :)

I suppose this feature will not work when the user has older versions of Node installed, right? (Since as I understand it, node-gyp will download the corresponding minor version source, which won't have the new features in yet).

@TooTallNate
Copy link
Contributor

@arturadib You're correct about node-gyp downloading the source tarball, however node-gyp also copies over newer versions of the gyp config files when they exist from its "legacy" dir. Eventually this "fixing" hopefully won't be necessary, and node-gyp can just use the node version's gypi files as they come, but for now (at least until 0.8) node-gyp has to do some "cleanup" on the dev files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants