Mrk Fldig
Mrk Fldig

Reputation: 4486

Install node and opencv on windows 8 using NPM

I seem to be having issues installing opencv with npm on windows 8 and was wondering if anyone could offer some pointers.

Errors are as follows, I know the obvious is install pkg-config but I can't seem to find any documentation on how to do this?:

    C:\Users\Marc>npm install opencv
\
> [email protected] preinstall C:\Users\Marc\node_modules\opencv
> node-gyp clean rebuild


C:\Users\Marc\node_modules\opencv>node "C:\Program Files\nodejs\node_modules\n
pm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean rebuild

'pkg-config' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to 'pkg-config --libs opencv' returned exit status 1. while trying to
load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_module
s\npm\node_modules\node-gyp\lib\configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:
12)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "clean" "rebuild"
gyp ERR! cwd C:\Users\Marc\node_modules\opencv
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
npm ERR! [email protected] preinstall: `node-gyp clean rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp clean rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls opencv
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "opencv"
npm ERR! cwd C:\Users\Marc
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Marc\npm-debug.log
npm ERR! not ok code 0

Upvotes: 4

Views: 1848

Answers (1)

Bob
Bob

Reputation: 66

I'm still working on getting this going in win8 with VS2013, but I found several of the dependencies I needed at http://www.gtk.org/download/win32.php. You can find pkg-config there and some other things that it depends on. An answer that has all of what I've already done is at How to install pkg config in windows?. I'm dealing with different problems now, but I hope this helps!

UPDATE

I got it working now on my laptop. I believe the secret, after getting pkg-config and its dependencies all installed, was the opencv.pc file. It has to point to your installation of opencv, and point by version to a bunch of the libs. Here's what ended up in mine:

# Package Information for pkg-config

prefix=C:/OpenCV249/opencv
exec_prefix=${prefix}/bin
libdir=${prefix}/build/x64/vc11/lib
includedir_old=${prefix}/build/include/opencv
includedir_new=${prefix}/build/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 2.4.9
Libs: ${libdir}/opencv_core249 ${libdir}/opencv_imgproc249 ${libdir}/opencv_highgui249 ${libdir}/opencv_ml249 ${libdir}/opencv_video249 ${libdir}/opencv_features2d249 ${libdir}/opencv_calib3d249 ${libdir}/opencv_objdetect249 ${libdir}/opencv_contrib249 ${libdir}/opencv_legacy249 ${libdir}/opencv_flann249

Cflags: ${includedir_old} ${includedir_new}

I placed this file in its own folder, and then created the PKG_CONFIG_PATH environment variable with that folder as its value. If I get feeling ambitious, maybe I'll see if I can get it working with OpenCV 3.0.0.

I hope this helps!

Upvotes: 5

Related Questions