My issue is that 'npm install dv' fails on Windows 10 with VS2013.
The error displayed is:
npm ERR! [email protected] install:
node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. <snip>
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)
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:
- If the option is undocumented and shouldn't be used, then switching it off for the entire build seems better to me
- common.gyp already has a 'OS=="win"' conditional section, and I'm lazy
- 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