opencv4nodejs icon indicating copy to clipboard operation
opencv4nodejs copied to clipboard

Cant build on windows 10

Open kolep8 opened this issue 6 years ago • 30 comments

Using 10.3.0 nodejs on Windows 10 I run "npm install --save opencv4nodejs"

Done Building Project "C:\test\node_modules
\opencv-build\opencv\build\INSTALL.vcxproj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

After that I see lots of missing files errors and then build process fails, for example one of missing files:

C:\test\node_modules\opencv4nodejs\cc\core\
Size.h(1): fatal error C1083: Cannot open include file: 'opencv2/core.hpp': No such file or di
rectory (compiling source file ..\cc\CustomMatAllocator.cc) [C:\test\node_modules\opencv4nodejs\build\opencv4nodejs.vcxproj]

kolep8 avatar May 31 '18 04:05 kolep8

Are you using your own OpenCV build or the auto build. In the latter case, did the auto build(the opencv-build package)succeed/execute?

justadudewhohacks avatar Jun 01 '18 06:06 justadudewhohacks

I am trying auto build

After first build/succeed message

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.

and then lots of files cant be included, just copied some of names:

fatal error C1083: Cannot open include file: 'opencv2/core.hpp': No such file
 or directory (compiling source file ..\cc\cvTypes\cvTypes.cc)

fatal error C1083: Cannot open include file: 'opencv2/highgui.hpp':
 No such file or directory (compiling source file ..\cc\cvTypes\videoCaptureProps.cc)

fatal error C1083: Cannot open include file: 'opencv2/core.hpp': No such file
or directory (compiling source file ..\cc\core\Mat.cc)

fatal error C1083: Cannot open include file: 'opencv2/core.hpp': No such file or dir
ectory (compiling source file ..\cc\core\Vec.cc)

last lines from powershell:

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\it\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\exe\\nodejs\\node.exe" "C:\\Users\\it\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files (x86)\no\node_modules\opencv4nodejs
gyp ERR! node -v v10.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Last lines from log:


810 verbose stack Error: [email protected] install: `node-gyp rebuild`
810 verbose stack Exit status 1
810 verbose stack     at EventEmitter.<anonymous> (C:\Users\it\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:304:16)
810 verbose stack     at EventEmitter.emit (events.js:182:13)
810 verbose stack     at ChildProcess.<anonymous> (C:\Users\it\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
810 verbose stack     at ChildProcess.emit (events.js:182:13)
810 verbose stack     at maybeClose (internal/child_process.js:961:16)
810 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

kolep8 avatar Jun 01 '18 10:06 kolep8

Can you check whether the include dir and libraries are present in node_modules/opencv-build/build? Obviously the include directory is missing.

justadudewhohacks avatar Jun 01 '18 18:06 justadudewhohacks

When I am running "opencv4nodejs" installation all folders are deleted after fail. So I cant check.

This time I tried just "npm install opencv-build" - this builded opencv without any issues. and those files what was missing, is found in folders. Then I tried "npm install --save opencv4nodejs" and it failed right after git checkout:

error: unable to create file samples/winrt_universal/VideoCaptureXAML/video_capture_xaml/video_capture_xaml.WindowsPhone/video_capture_xaml.WindowsPhone.vcxproj.filters: Filename too long
error: unable to create file samples/winrt_universal/VideoCaptureXAML/video_capture_xaml/video_capture_xaml.WindowsPhone/video_capture_xaml.WindowsPhone_TemporaryKey.pfx: Filename too long
Checking out files: 100% (5879/5879), done.
fatal: unable to checkout working tree

and installing process stopped

kolep8 avatar Jun 01 '18 18:06 kolep8

Okay, but that's a git issue. Usually git should accept much longer filenames, so not sure whats the issue there.

justadudewhohacks avatar Jun 01 '18 18:06 justadudewhohacks

Tried again, results are: npm install opencv-build - has all files what cant be found by next command npm install opencv4nodejs - cant find opencv files

Looks like issue could be in "opencv4nodejs" execution process. if running "opencv-build" on its own has all files whats needed

npm version - 6.1.0 nodejs - 10.3.0

is there anything else I could try?

kolep8 avatar Jun 01 '18 20:06 kolep8

Given that opencv-build indeed builds without any issue you should have an include directory at node_modules\opencv-build\opencv\build\include, which contains the subdirectories opencv and opencv2 with all the header files, a library directory at node_modules\opencv-build\opencv\build\lib\Release containing the .lib files and a binary directory node_modules\opencv-build\opencv\build\bin\Release with .dlls.

Not sure why the install script doesn't find the include directory in your case, but you could also disable the autobuild flag after installing opencv-build and set the envs OPENCV_INCLUDE_DIR and OPENCV_LIB_DIR manually to the corresponding directories.

justadudewhohacks avatar Jun 01 '18 21:06 justadudewhohacks

All required Env variables was set.

info install OPENCV4NODEJS_DISABLE_AUTOBUILD is set
info install skipping auto build...

but even with it, it fails to find those files:

c:\program files (x86)\test\node_modules\opencv4nodejs\cc\core\coreUtils.h(2): fatal error C1083: 
Cannot open include file: 'opencv2/core.hpp': No such file
or directory (compiling source file ..\cc\core\core.cc) 
[C:\Program Files (x86)\test\node_modules\opencv4nodejs\build\opencv4nodejs.vcxproj]
c:\program files (x86)\test\node_modules\opencv4nodejs\cc\cvtyp
es\imgprocConstants.h(2): fatal error C1083: Cannot open include file: 'opencv2/core.hpp': No
such file or directory (compiling source file ..\cc\cvTypes\imgprocConstants.cc) [C:\Program F
iles (x86)\test\node_modules\opencv4nodejs\build\opencv4nodejs.vcxproj]

kolep8 avatar Jun 02 '18 07:06 kolep8

also checking OPENCV_INCLUDE_DIR in CMD it gives correct path. Could this issue be due npm version?

kolep8 avatar Jun 02 '18 08:06 kolep8

That's odd. I can't think of any reason why it complains. Not sure if it is related to npm, I am using npm 5.6.0 right now, which comes with node-gyp 3.6.2.

In case you want to debug the issue, the script node-gyp uses to get the include directory is located in lib/includes.js. You could clone the repo and replace the console.log with a throw new Error(resolvePath(process.env.OPENCV_INCLUDE_DIR)) to log and investigate the final path, since console.log doesn't print to the console in this script.

justadudewhohacks avatar Jun 02 '18 09:06 justadudewhohacks

Throw also shows correct path: Error: C:/Program Files (x86)/test/node_modules/opencv-build/opencv/build/include

node-gyp -v v3.6.2

kolep8 avatar Jun 02 '18 10:06 kolep8

@justadudewhohacks Maybe you can share compressed "node_modules" with package.json and package-lock.json, where "face-recognition.js" "opencv4nodejs" would be installed for windows.

Thanks :+1:

kolep8 avatar Jun 03 '18 04:06 kolep8

I don't want to maintain precompiled versions of this package for every single operating system, node abi and OpenCV setup for every single release, sorry.

justadudewhohacks avatar Jun 03 '18 21:06 justadudewhohacks

Hello, I have the same problem when i try to install the Opencv module.

772 warn [email protected] No description 773 warn [email protected] No repository field. 774 verbose stack Error: [email protected] install: node-gyp rebuild 774 verbose stack Exit status 1 774 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16) 774 verbose stack at emitTwo (events.js:126:13) 774 verbose stack at EventEmitter.emit (events.js:214:7) 774 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 774 verbose stack at emitTwo (events.js:126:13) 774 verbose stack at ChildProcess.emit (events.js:214:7) 774 verbose stack at maybeClose (internal/child_process.js:925:16) 774 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 775 verbose pkgid [email protected] 776 verbose cwd C:\Users\rafael.pereira\Desktop\node 777 verbose Windows_NT 10.0.17134 778 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "opencv4nodejs" 779 verbose node v8.11.1 780 verbose npm v5.6.0 781 error code ELIFECYCLE 782 error errno 1 783 error [email protected] install: node-gyp rebuild 783 error Exit status 1 784 error Failed at the [email protected] install script. 784 error This is probably not a problem with npm. There is likely additional logging output above. 785 verbose exit [ 1, true ]

rafaP avatar Jun 12 '18 16:06 rafaP

Could you please share the full error log? The error message is not shown in the log you posted

justadudewhohacks avatar Jun 12 '18 18:06 justadudewhohacks

Hello, here it is the debug log and the terminal log.

Plus i have the python installed, but it keeps not working.

2018-06-13T08_41_40_572Z-debug.log

terminal log.txt

rafaP avatar Jun 13 '18 08:06 rafaP

You know what I'm doing wrong in there?

rafaP avatar Jun 15 '18 08:06 rafaP

I need this for a project i'm working.

rafaP avatar Jun 18 '18 15:06 rafaP

Sorry for the late reply. Thanks for sharing the log. The error message clearly says that the python executable could not be found, which is required to run node-gyp:

gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "C:\Users\rafael.pereira\AppData\Local\Programs\Python\Python36-32\python.EXE", you can set the PYTHON env variable. gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19) gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16) gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21) gyp ERR! System Windows_NT 10.0.17134 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\rafael.pereira\Desktop\node\node_modules\opencv4nodejs gyp ERR! node -v v8.11.1 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok

Is python in your system path, what happens if you run python --version? Looks like you set the python environment variable to the executable rather then the directory? Try to strip python.EXE from the path, eg: C:\Users\rafael.pereira\AppData\Local\Programs\Python\Python36-32.

justadudewhohacks avatar Jun 18 '18 15:06 justadudewhohacks

image

rafaP avatar Jun 18 '18 15:06 rafaP

Ah okay. However, this is a node-gyp issue and not the issue of opencv4nodejs. I would recommend you to look the error message up at node-gyp. Googling the error message you can already find a lot of people having the same issue as yours.

The only thing that I would suggest you to try is to set the python path in your npm config: npm config set python "C:\Users\rafael.pereira\AppData\Local\Programs\Python\Python36-32\python.exe". Otherwise I am clueless.

justadudewhohacks avatar Jun 18 '18 15:06 justadudewhohacks

It needs Python 2 instead of 3. and now it's working.

Thanks for the support, if i find more problems i will report.

rafaP avatar Jun 19 '18 09:06 rafaP

Strange, I am using python 3.5. But atleast it is working now.

justadudewhohacks avatar Jun 19 '18 10:06 justadudewhohacks

Yes. Thanks for the support.

rafaP avatar Jun 19 '18 11:06 rafaP

If you're running Windows 10, do yourself a HUGE favor and start using WSL (and docker if appropriate) and you'll all but stop seeing Windows specific issues while doing Nodejs dev.

rainabba avatar Jul 12 '18 21:07 rainabba

Hi Team,

While installing opencv4nodejs, getting error, please assist

  1. Downloaded and extracted opencv-3.4.2-vc14_vc15.exe

  2. Installed build tools with "npm install --global windows-build-tools"

  3. Created below environement variables OPENCV_DIR=D:\opencv OPENCV_BIN_DIR=d:\opencv\build\x64\vc14\bin OPENCV_INCLUDE_DIR=d:\opencv\build\include OPENCV_LIB_DIR=d:\opencv\build\x64\vc14\lib

    OPENCV4NODEJS_DISABLE_AUTOBUILD=1 Added %OPENCV_BIN_DIR% in path varaible

Error: C:\Users\username>npm i -g opencv4nodejs

[email protected] install C:\Users\username\AppData\Roaming\npm\node_modules\opencv4nodejs\node_modules\opencv-build> node ./install.js

info install OPENCV4NODEJS_DISABLE_AUTOBUILD is set info install skipping auto build...

[email protected] install C:\Users\username\AppData\Roaming\npm\node_modules\opencv4nodejs node-gyp rebuild

C:\Users\username\AppData\Roaming\npm\node_modules\opencv4nodejs>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. C:\Users\username\AppData\Roaming\npm\node_modules\opencv4nodejs\build\opencv4nodejs.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is c orrect, and that the file exists on disk. gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23) gyp ERR! stack at emitTwo (events.js:126:13) gyp ERR! stack at ChildProcess.emit (events.js:214:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) gyp ERR! System Windows_NT 10.0.15063 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\username\AppData\Roaming\npm\node_modules\opencv4nodejs gyp ERR! node -v v8.11.4 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\username\AppData\Roaming\npm-cache_logs\2018-09-06T07_09_58_012Z-debug.log

savtambe avatar Sep 06 '18 07:09 savtambe

I seem to have the exact same issue as @kolep8

c:\users\anna\desktop\vmm\sqclassifier\vmm\node_modules\opencv4nodejs\cc\modules\features2d\detectors\SimpleBlobDetectorParams.h(3): fatal error C1083: Cannot open include file: 'opencv2/features2d.hpp': No such file or directory (compiling source file ..\cc\modules\features2d\detectors\SimpleBlobDetectorParams.cc) [C:\Users\Anna\Desktop\VMM\SQclassifier\VMM\node_modules\opencv4nodejs\build\opencv4nodejs.vcxproj] gyp ERR! build error gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exefailed with exit code: 1 gyp ERR! stack at ChildProcess.onExit(C:\Users\Anna\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:160:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12) gyp ERR! System Windows_NT 10.0.17134 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Anna\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\Anna\Desktop\VMM\SQclassifier\VMM\node_modules\opencv4nodejs gyp ERR! node -v v9.5.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install:node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Anna\AppData\Roaming\npm-cache_logs\2018-11-24T17_23_40_590Z-debug.log `

Still no dice?

As for @savtambe it seems that you have a separate issue with MSBuild as you have MSB error. You have to look at this line in your error log: error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

AnnaMoudra avatar Nov 24 '18 17:11 AnnaMoudra

I solved my issue by using auto build and the -msvs_version=2017 flag. First I had to delete the VCTargetsPath from Environment Variables which is used for VS 2015 only (make sure to put it back, if you want to use VS 2015 later). I had to also make sure to close and reopen PowerShell every time I have used VS 2015 as it has left some variables set, which was messing with the VS 2017 build. I am noting this as I have seen many recomendations to keep just one version of VS, which is clearly not needed And finally, I had to delete the .node-gyp directory from C:\Users\<username>\

AnnaMoudra avatar Nov 24 '18 20:11 AnnaMoudra

I m getting error when starting application on Ubuntu 18.04 LTS node 8.11.3 npm 6.4.1

module.js:681 return process.dlopen(module, path._makeLong(filename)); ^

Error: /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0: undefined symbol: g_log_structured_standard at Object.Module._extensions..node (module.js:681:18) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (/projectPath/node_modules/opencv4nodejs/lib/cv.js:17:8) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) [nodemon] app crashed - waiting for file changes before starting...

AniruddhPurohit avatar Mar 04 '19 12:03 AniruddhPurohit

Did you solve the problem?

I m getting error when starting application on Ubuntu 18.04 LTS

node 8.11.3 npm 6.4.1 module.js:681 return process.dlopen(module, path._makeLong(filename)); ^

Error: /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0: undefined symbol: g_log_structured_standard at Object.Module._extensions..node (module.js:681:18) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (/projectPath/node_modules/opencv4nodejs/lib/cv.js:17:8) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) [nodemon] app crashed - waiting for file changes before starting...

Did you solve the problem?

ankitOneNineNineNine avatar Nov 20 '20 02:11 ankitOneNineNineNine