creatale / node-dv

A node.js library for processing and understanding scanned documents
Other
340 stars 72 forks source link

Install fails at node-gyp rebuild on Windows #33

Open Brigadier1-9 opened 8 years ago

Brigadier1-9 commented 8 years ago

My issue is that 'npm install dv' fails on Windows 10 with VS2013. The error displayed is: npm ERR! dv@1.10.1 install:node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the dv@1.10.1 install script 'node-gyp rebuild'.

` If you watch the compiler output or check the logs you see: `C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h(4774): error C3861: '__uncaught_exception': identifier not found (..\..\..\deps\opencv\modules\core\src\parallel.cpp) [C:\Development\temp1\node_modules\dv\build\deps \opencv\libopencv.vcxproj]` I've had a dig and suspect the issue is actually coming from node-gyp; the pre-processor options in the vcxproj files generated by node-gyp include the '_HAS_EXCEPTIONS=0' flag (in pre-processor options) which, according to Microsoft, is an undocumented option that is evil and should not be used (OK, I'm oversimplifying here - see [https://connect.microsoft.com/VisualStudio/feedback/details/811347/compiling-vc-12-0-with-has-exceptions-0-and-including-concrt-h-causes-a-compiler-error](url)) This option tells the compiler the code has no exception handling, and then causes issues with exception macros like '__uncaught_exception' I can find no obvious option in the dv gyp files that would be responsible for putting that option in, and am almost at the limit of my node-gyp knowledge.... However, I have managed to fix this in dv by changing common.gyp to remove the _HAS_EXCEPTIONS=0 using a 'defines!' (undefine): ....['OS=="win"', { **'defines!' : [ '_HAS_EXCEPTIONS=0' ],** 'configurations': {.... In theory, it may be better to define this only in the opencv.gyp, as that is the only module that causes this error, but I didn't for several reasons: 1) If the option is undocumented and shouldn't be used, then switching it off for the entire build seems better to me 2) common.gyp already has a 'OS=="win"' conditional section, and I'm lazy 3) I have spent far too much time on this already (although I have learnt a lot!) I don't have access to other build windows environment combinations (only one Windows dev PC here, the others are OSX or Linux) so I can't easily do proper testing on combinations of node-gyp/msvc/msbuild etc, so reluctant to issue a pull request - just throwing this out there to see if it helps others with the same problem. After making the change to common.gyp, I can issue a 'node-gyp rebuild' and then an 'npm test' and they all pass. My versions: Node: 4.2.1 Node-gyp: 3.3.0 (I installed this with -g so I could manually run node-gyp configure and check the generated project files) Visual Studio: 12.0.40629.00 Update 5
rashfael commented 8 years ago

Got CI with appveyor to run and could reproduce this error.

denysvitali commented 8 years ago

A branch has been merged, is the issue fixed?

orkideh commented 8 years ago

I am trying to install on windows 10 x64 almost same error. VS last version community , node 5.11.1 , npm 3.8.6. I attached my logfile

npm-debug.txt

Brigadier1-9 commented 8 years ago

Hi!

I've had a quick look at your debug and I think you are getting further than I was, so you may have a different problem. The issue is that the 'Failed at node-gyp rebuild' is such a generic error that it could be almost anything.

I actually wound up installing node-gyp (npm install -g node-gyp) then cloned the repository with git clone (somewhere outside of your node project) in order to run 'node gyp configure' then 'node gyp build' by hand; that then revealed the exact error (which, unless I am missing it, I can't see in your debug.txt)

When it compiles you can then npm install (folder path) from your node project.

If it helps any, I have a pre-fixed branch - feel free to clone that one instead.

orkideh commented 8 years ago

Hi, Very interesting last night i was play with code to make it work. I download all source and compile with node-gyp configure and node-gyp build, then i return to parent folder and try to install with npm install dv and it works after that. Without doubt this way is wrong to make it work but i guess i fixed something accidentally.

Brigadier1-9 commented 8 years ago

Very weird, but as long as it works!

There is an error in the Zxing barcode reader that we’ve just discovered too by the way – it’s a memory leak and it crashes after parsing a number of images. We have a fix, I’ll open a new issue for it shortly.

orkideh commented 8 years ago

Thank you very much

kneumei commented 8 years ago

@Brigadier1-9 FWIW, your fork fixed by build issue as well.

win 10 x64, node 6.2.1, npm 3.9.3