node-v4l2camera
node-v4l2camera copied to clipboard
field ‘timestamp’ has incomplete type error during build.
I get the following error during installation.
$ npm install
> [email protected] install /home/rich/Projects/tmp/v4l2camera
> node-gyp rebuild
make: Entering directory '/home/rich/Projects/tmp/v4l2camera/build'
CXX(target) Release/obj.target/v4l2camera/v4l2camera.o
CC(target) Release/obj.target/v4l2camera/capture.o
In file included from ../capture.h:7:0,
from ../capture.c:1:
/usr/include/linux/videodev2.h:2127:20: error: field ‘timestamp’ has incomplete type
struct timespec timestamp;
^~~~~~~~~
v4l2camera.target.mk:112: recipe for target 'Release/obj.target/v4l2camera/capture.o' failed
make: *** [Release/obj.target/v4l2camera/capture.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from ../node_modules/nan/nan_callbacks.h:83:0,
from ../node_modules/nan/nan.h:146,
from ../v4l2camera.cc:3:
../node_modules/nan/nan_callbacks_12_inl.h: In instantiation of ‘v8::Local<v8::Function> Nan::FunctionCallbackInfo<T>::Callee() const [with T = v8::Value]’:
../v4l2camera.cc:255:48: required from here
../node_modules/nan/nan_callbacks_12_inl.h:108:71: warning: ‘v8::Local<v8::Function> v8::FunctionCallbackInfo<T>::Callee() const [with T = v8::Value]’ is deprecated: Use Data() to explicitly pass Callee instead [-Wdeprecated-declarations]
inline v8::Local<v8::Function> Callee() const { return info_.Callee(); }
^
In file included from /home/rich/.node-gyp/7.5.0/include/node/node.h:42:0,
from ../node_modules/nan/nan.h:47,
from ../v4l2camera.cc:3:
/home/rich/.node-gyp/7.5.0/include/node/v8.h:8119:17: note: declared here
Local<Function> FunctionCallbackInfo<T>::Callee() const {
^~~~~~~~~~~~~~~~~~~~~~~
I was able to fix it by adding #include <time.h>
to the top of capture.h
#ifndef CAMERA_H
#define CAMERA_H
#include <time.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <linux/videodev2.h>
#ifndef __V4L2_COMMON__
# define CAMERA_OLD_VIDEODEV2_H
#endif
@RichAyotte it doesn't seem your like change has been pulled in yet. Can you recommend which of the forks one ought to use? Or is progress on this npm module at a standstill?
For the sake of completeness, here are my errors:
$ npm i v4l2camera
> [email protected] install /home/troyw/code-local/experiments/v4l2camera/node_modules/v4l2camera
> node-gyp rebuild
make: Entering directory '/home/troyw/code-local/experiments/v4l2camera/node_modules/v4l2camera/build'
CC(target) Release/obj.target/v4l2camera/capture.o
In file included from ../capture.h:7:0,
from ../capture.c:1:
/usr/include/linux/videodev2.h:2190:20: error: field ‘timestamp’ has incomplete type
struct timespec timestamp;
^~~~~~~~~
v4l2camera.target.mk:112: recipe for target 'Release/obj.target/v4l2camera/capture.o' failed
make: *** [Release/obj.target/v4l2camera/capture.o] Error 1
make: Leaving directory '/home/troyw/code-local/experiments/v4l2camera/node_modules/v4l2camera/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/troyw/.nvm/versions/node/v7.10.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.10.0-24-generic
gyp ERR! command "/home/troyw/.nvm/versions/node/v7.10.0/bin/node" "/home/troyw/.nvm/versions/node/v7.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/troyw/code-local/experiments/v4l2camera/node_modules/v4l2camera
gyp ERR! node -v v7.10.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/home/troyw/code-local/experiments/v4l2camera/package.json'
npm WARN v4l2camera No description
npm WARN v4l2camera No repository field.
npm WARN v4l2camera No README data
npm WARN v4l2camera No license field.
npm ERR! Linux 4.10.0-24-generic
npm ERR! argv "/home/troyw/.nvm/versions/node/v7.10.0/bin/node" "/home/troyw/.nvm/versions/node/v7.10.0/bin/npm" "i" "v4l2camera"
npm ERR! node v7.10.0
npm ERR! npm v4.2.0
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 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the v4l2camera package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs v4l2camera
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls v4l2camera
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/troyw/.npm/_logs/2017-06-26T20_54_17_262Z-debug.log
I reported the issue but didn't submit a PR. The fix is simple though, just add #include <time.h> to the top of capture.h.
It seems distribution dependent problems around linux-headers.
Ubuntu-17.04's videodev2.h
includes <sys/time.h>
not libc's <time.h>
above.
The videodev2.h
also uses struct timeval
not in the libc <time.h>
.
If the fix required, #include <sys/time.h>
would be valid.
Or <linux/time.h>
would be better if:
#include <stdio.h>
#include <sys/time.h>
int main() {
printf("timespec: %zu\n", sizeof (struct timespec));
printf("timeval: %zu\n", sizeof (struct timeval));
return 0;
}
and
#include <stdio.h>
#include <linux/time.h>
int main() {
printf("timespec: %zu\n", sizeof (struct timespec));
printf("timeval: %zu\n", sizeof (struct timeval));
return 0;
}
would be different in some platforms.
I have this error when try to install with npm i --save v4l2camera
. How i can install this?
I agree with meganetaaan's fix above, it worked for me.
The fix got applied in e0bff49 and reverted in the very next commit c2bb744 - I still get the same error
Has anyone found the fix. I'm also facing the same issue.
@bellbind Are you waiting for a PR or trying to decide on implementation?
Is this gunna get fixed?
It's Not merged, already requests have been sent. Plz merge or tell me some alternative PLZZZ