justadudewhohacks / justadudewhohacks/opencv4nodejs
Error when rebuilding - fatal error: 'opencv2/core.hpp' file not found
- Dominant language
- C++
- Stars
- 5.1k
- Forks
- 826
- PR merge metrics
- No merged PRs in 30d
Description
Today I was upgrading from opencv4nodejs `4.9.1` to `5.3.0` when I ran into this error.
I am using opencv4nodejs in an electron environment and there the below listed error message is triggered when using electron-rebuild, which I guess is similar to this command as it produces more or less the same error.
```
node-gyp rebuild --jobs max
```
The building of both opencv4nodejs and opencv-build seems to work fine. The build output has lots of warnings, but ends successfully (see attached file). After that the error is thrown when rebuilding gets triggered.
I have looked at these issues but their solutions do not work for me
https://github.com/justadudewhohacks/opencv4nodejs/issues/591 - I do not have tesseract installed
https://github.com/justadudewhohacks/opencv4nodejs/issues/618 - disabling autobuild is currently not an option for me
Anyone an idea? In the build files I saw that opencv `3.4.6` gets installed by default. Might it make a difference if one builds opencv 4.x with `autoBuildOpencvVersion`?
# Error Message
```
An unhandled error occurred inside electron-rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.5
gyp info using node@12.4.0 | darwin | x64
gyp info find Python using Python version 2.7.16 found at "/usr/local/opt/python@2/bin/python2.7"
gyp info spawn /usr/local/opt/python@2/bin/python2.7
gyp info spawn args [
gyp info spawn args '/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/node_modules/electron-rebuild/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/app/node_modules/opencv4nodejs/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/node_modules/electron-rebuild/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/fakob/.electron-gyp/4.2.10/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/fakob/.electron-gyp/4.2.10',
gyp info spawn args '-Dnode_gyp_dir=/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/node_modules/electron-rebuild/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/fakob/.electron-gyp/4.2.10/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/app/node_modules/opencv4nodejs',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o
In file included from ../cc/opencv4nodejs.cc:2:
In file included from ../cc/ExternalMemTracking.h:1:
../cc/macros.h:2:10: fatal error: 'opencv2/core.hpp' file not found
#include
^~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/node_modules/electron-rebuild/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:200:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/Cellar/node/12.4.0/bin/node" "/Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/node_modules/electron-rebuild/node_modules/.bin/node-gyp" "rebuild" "--target=4.2.10" "--arch=x64" "--dist-url=https://electronjs.org/headers" "--build-from-source"
gyp ERR! cwd /Users/fakob/_jakob/work/fakob_MoviePrintApp_130515/03_Programming/02_Setups/05_Electron/MoviePrint_v004/app/node_modules/opencv4nodejs
gyp ERR! node -v v12.4.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
Failed with exit code: 1
```
# Auto Build - ~~Full Error Log~~
auto build seems to be successfull
[yarn --verbose build output.txt](https://github.com/justadudewhohacks/opencv4nodejs/files/3736504/yarn.--verbose.build.output.txt)
Contributor guide
Research direction
Start with binding.gyp and the native sources cc/opencv4nodejs.cc, cc/ExternalMemTracking.h, and cc/macros.h, then compare the successful auto-build output with the electron-rebuild node-gyp invocation. Determine why the OpenCV include path is unavailable during Electron rebuild and verify the fix by rerunning electron-rebuild for the reported Electron target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, electron, nodejs
- Domain
- build-system, desktop-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100