serialport / node-serialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
https://serialport.io
MIT License
5.79k stars 1.01k forks source link

Build fails with "unresolved externals" [Win 7 VS11] when building with nw-gyp #162

Closed techninja closed 11 years ago

techninja commented 11 years ago

Almost seems like you can never cover all the bases, Windows especially. :P

So I need a compiled version of node-serialport for windows to distribute with my node-webkit app. With the right version of Python, building works great via standard gyp, but with nw-gyp, it complains of the following unresolved externals:

enumser.obj : error LNK2001: unresolved external symbol __imp__RegQueryValueExA@24 [serialport.vcxproj]
enumser.obj : error LNK2001: unresolved external symbol _EnumPortsA@24 [serialport.vcxproj]
enumser.obj : error LNK2001: unresolved external symbol __imp__RegOpenKeyExA@20 [serialport.vcxproj]
enumser.obj : error LNK2001: unresolved external symbol __imp__RegQueryInfoKeyA@48 [serialport.vcxproj]
enumser.obj : error LNK2001: unresolved external symbol __imp__RegEnumValueA@32 [serialport.vcxproj]
enumser.obj : error LNK2001: unresolved external symbol __imp__RegCloseKey@4 [serialport.vcxproj]
Release\serialport.node : fatal error LNK1120: 6 unresolved externals [serialport.vcxproj]

After hours of googling and lots of failed leads, I've found the _only_ problem are two missing additional dependencies, AdvAPI32.Lib and WinSpool.Lib, for registry access and enumports. After adding these two to the Additional Dependencies in the serialport.vcxproj after configure, it builds a treat.

If anything, I have no idea where this fix should be made, here in node-serialport, or off in nw-gyp configure. If anything, it should be a good thing to have this documented here for the next weary traveler trying to make a node-webkit desktop app that needs serial port access :palm_tree:

Oh, and thanks to node-serialport, our project went to the white house and was used by the President! iPad -> Raspberry Pi WAP -> node express -> serialport -> WaterColorBot!

voodootikigod commented 11 years ago

Will look into it. I am not super experienced with windows, but have friends that are so should get you something right quick. The project is AWESOME! Would love to feature it!

On Thu, May 9, 2013 at 2:52 AM, James T notifications@github.com wrote:

Almost seems like you can never cover all the bases, Windows especially. :P

So I need a compiled version of node-serialport for windows to distribute with my node-webkit app. With the right version of Python, building works great via standard gyp, but with nw-gyphttps://github.com/rogerwang/node-webkit/wiki/Build-native-modules-with-nw-gyp, it complains of the following unresolved externals:

enumser.obj : error LNK2001: unresolved external symbol impRegQueryValueExA@24 [serialport.vcxproj] enumser.obj : error LNK2001: unresolved external symbol _EnumPortsA@24 [serialport.vcxproj] enumser.obj : error LNK2001: unresolved external symbol impRegOpenKeyExA@20 [serialport.vcxproj] enumser.obj : error LNK2001: unresolved external symbol impRegQueryInfoKeyA@48 [serialport.vcxproj] enumser.obj : error LNK2001: unresolved external symbol impRegEnumValueA@32 [serialport.vcxproj] enumser.obj : error LNK2001: unresolved external symbol impRegCloseKey@4 [serialport.vcxproj] Release\serialport.node : fatal error LNK1120: 6 unresolved externals [serialport.vcxproj]

After hours of googling and lots of failed leads, I've found the _only_problem are two missing additional dependencies, AdvAPI32.Lib and WinSpool.Lib, for registry access and enumports. After adding these two to the Additional Dependencies in the serialport.vcxproj after configure, it builds a treat.

If anything, I have no idea where this fix should be made, here in node-serialport, or off in nw-gyp configure. If anything, it should be a good thing to have this documented here for the next weary traveler trying to make a node-webkit desktop app that needs serial port access [image: :palm_tree:]

Oh, and thanks to node-serialport, our projecthttp://sylviashow.com/blog/super-awesome-sylvia/2013/04/27/my-crazy-dc-adventurewent to the white house and was used by the President! iPad -> Raspberry Pi WAP -> node express -> serialport -> WaterColorBot!

— Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/162 .

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHubhttp://github.com/voodootikigod

The things I make that you should check out: SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ | PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

Help me end the negativity on the internet, share thishttp://jsconf.eu/2011/an_end_to_negativity.html .

techninja commented 11 years ago

Of course! Couldn't have done it without you and the community. The two main projects are cncserver for the direct hardware interaction, and watercolorbot as the split-off for the client-side SVG tracing interface, and now soon to be node-webkit standalone app.

JayBeavers commented 11 years ago

These are very common libraries to include in most apps so there's likely a divergence between nw-gyp and node-gyp which is causing the issue.

I did some spelunking through nw-gyp and node-gyp. In node-gyp, I found a reference to the missing library advapi32 in the file msvs_emulation.py (https://github.com/TooTallNate/node-gyp/blob/master/gyp/pylib/gyp/msvs_emulation.py). This file is 8 months old. In nw-gyp, this file is missing. nw-gyp contains a copy of node-gyp which is about a year old.

So the fix here imho is to ask the nw-gyp project to synchronize with a newer copy of node-gyp. This is not an issue with node-serialport. I will submit this issue to nw-gyp.

voodootikigod commented 11 years ago

Hey James, I believe this has been fixed, any way to verify it?

Also can you email me directly I have a private question for you -- voodootikigod@gmail.com

Thanks!

On Fri, May 10, 2013 at 4:16 AM, James T notifications@github.com wrote:

Of course! Couldn't have done it without you and the community. The two main projects are cncserver https://github.com/techninja/cncserver for the direct hardware interaction, and watercolorbothttps://github.com/techninja/watercolorbotas the split-off for the client-side SVG tracing interface, and now soon to be node-webkit standalone app.

— Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/162#issuecomment-17709184 .

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHubhttp://github.com/voodootikigod

The things I make that you should check out: SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ | PromoteJS http://promotejs.com/ | Minute With http://minutewith.com/

Help me end the negativity on the internet, share thishttp://jsconf.eu/2011/an_end_to_negativity.html .

techninja commented 11 years ago

Well, just tested with brand new master pulls, and it hasn't been "fixed", though a manual fix has been properly documented in nw-gyp issue 10 above. My guess is they have bigger fish to fry.

zuzkins commented 11 years ago

for me the changes @JayBeavers introduced in https://github.com/JayBeavers/node-serialport/tree/SimplifyDependencies fixed the need to manually change the dependencies.

Thanks!

techninja commented 11 years ago

@zuzkins Awesome! Now why hasn't @JayBeavers submitted a pull request? :wink:

zuzkins commented 11 years ago

@techninja I believe it already has been merged, so go and try it :) https://github.com/voodootikigod/node-serialport/pull/186

techninja commented 11 years ago

38301551

techninja commented 11 years ago

Just attempted with brand new master pull of node-serialport and latest release of nw-gyp. Holy cow, totally works like a champ now. Good enough to close! Too bad the issue's been closed for 3 weeks now :smiley_cat:

mharsch commented 11 years ago

Can we get this pushed to npm? This impacted nodebotsday for several folks who were trying to get bootstrapped on windows and hitting this with node-serialport 1.1.1

JayBeavers commented 11 years ago

Let me pop a few more changes in tonight. I'd like to do a docs edit pass and update the enumser.cpp library, I can do these both in a couple of hours.

Chris has a new child and he owns the npm publish keys, so not sure when he'll be available to publish.