UrielCh / opencv4nodejs

ESM Nodejs bindings to OpenCV 3/4
MIT License
254 stars 51 forks source link

Unable to build in Ubuntu 22.04 - execv: Argument list too long #143

Open zzz08900 opened 5 months ago

zzz08900 commented 5 months ago

Is there some compatibility issue with node-gyp or gcc?

error /home/andrew/testProject/node_modules/@u4/opencv4nodejs: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /home/andrew/testProject/node_modules/@u4/opencv4nodejs
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@20.14.0 | linux | x64
gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"

gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/andrew/testProject/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 '/home/andrew/testProject/node_modules/@u4/opencv4nodejs/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/andrew/testProject/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/andrew/.cache/node-gyp/20.14.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/andrew/.cache/node-gyp/20.14.0',
gyp info spawn args '-Dnode_gyp_dir=/home/andrew/testProject/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/andrew/.cache/node-gyp/20.14.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/andrew/testProject/node_modules/@u4/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' ]
make: Entering directory '/home/andrew/testProject/node_modules/@u4/opencv4nodejs/build'
  CXX(target) Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o
g++: fatal error: cannot execute ‘/usr/lib/gcc/x86_64-linux-gnu/11/cc1plus’: execv: Argument list too long
compilation terminated.
make: *** [opencv4nodejs.target.mk:10236: Release/obj.target/opencv4nodejs/cc/opencv4nodejs.o] Error 1
make: Leaving directory '/home/andrew/testProject/node_modules/@u4/opencv4nodejs/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (/home/andrew/testProject/node_modules/node-gyp/lib/build.js:209:23)
gyp ERR! System Linux 6.5.0-35-generic
gyp ERR! command "/home/andrew/.nvm/versions/node/v20.14.0/bin/node" "/home/andrew/testProject/node_modules/@u4/opencv4nodejs/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /home/andrew/testProject/node_modules/@u4/opencv4nodejs
gyp ERR! node -v v20.14.0
gyp ERR! node-gyp -v v10.1.0
gyp ERR! not ok
Pnlvfx commented 5 months ago

+1

Pnlvfx commented 4 months ago

Can someone help us?

zzz08900 commented 4 months ago

A quick glance at opencv4nodejs.target.mk indicates somehow output stream of git clone and some other commands ends up pushed into DEFS_Release so this makefile is not going to work.

No idea how/why this happened. Also no idea what is responsible of generating this makefile.

Pnlvfx commented 4 months ago

I've fixed this error by removing OPENCV4NODEJS_DISABLE_AUTOBUILD=1 from the package.json and running:

export OPENCV4NODEJS_DISABLE_AUTOBUILD=1 npm install

It look like it's not reading the package.json environment

zzz08900 commented 4 months ago

Yeah sure you can install your own openCV and disable auto build all together. But the installation process is kinda painful for some OS and that's why we have all sorts of auto install scripts floating around, from Anaconda to build-opencv.