camme / node-nfc

A first try at binding libnfc to node. This project is right now not good enough to use.
68 stars 39 forks source link

Failing to install ā€“ libnfc #22

Closed stefanpearson closed 8 years ago

stefanpearson commented 8 years ago

I'm getting an error installing on OSX (after installing the dependencies through brew):

> node-gyp clean configure rebuild

  CXX(target) Release/obj.target/nfc/src/nfc.o
../src/nfc.cc:5:10: fatal error: 'nfc/nfc.h' file not found
#include <nfc/nfc.h>
         ^
1 error generated.
make: *** [Release/obj.target/nfc/src/nfc.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "clean" "configure" "rebuild"
gyp ERR! cwd /Users/Stefan/Projects/ribot/ripidrate-new/node_modules/nfc
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE

npm ERR! nfc@0.3.1 install: `node-gyp clean configure rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the nfc@0.3.1 install script 'node-gyp clean configure rebuild'.
npm ERR! This is most likely a problem with the nfc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp clean configure rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs nfc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls nfc
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Stefan/Projects/ribot/ripidrate-new/npm-debug.log

I noticed you mentioned this was a known issue with libnfc not being installed correctly (in the readme), how does one fix this?

jeroenvollenbrock commented 8 years ago

Hi there!

On OSX libnfc is available through homebrew. I'll try to add some pointers to the readme.

You can install libnfc by using brew install libnfc after homebrew has been installed

stefanpearson commented 8 years ago

Ah, I have done that already, following the readme šŸ˜›.

jeroenvollenbrock commented 8 years ago

@stefanpearson: Can you verify if "/usr/local/include/nfc/nfc.h" exists?

stefanpearson commented 8 years ago

Yep, it's there

jeroenvollenbrock commented 8 years ago

I'll try to reproduce this and get back to you ASAP.

stefanpearson commented 8 years ago

Thank you :)

jeroenvollenbrock commented 8 years ago

Could you try to replace the binding.gyp content with the following content and confirm if it fixes the problem?

{
  "targets": [ {
      "target_name": "nfc",
      "sources": [ "src/nfc.cc" ],
      "libraries": [ "-lnfc","-L/usr/local/lib/" ],
      "include_dirs": [
        "<!(node -e \"require('nan')\")",".","/usr/local/include/"
      ],
  } ]
}
stefanpearson commented 8 years ago

Ok this is strange, I was on Node 0.12 before, I've recently in the last few days installed 4.4.4 and am now receiving a different installation error:

> node-libnfc@0.1.0 install /Users/Stefan/Projects/Forks/node-libnfc
> ( cd src && node-gyp rebuild ) && gulp

  CXX(target) Release/obj.target/nfc/nfc.o
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
../nfc/util.hh:92:18: error: expected class name
    public node::ObjectWrap
                 ^
../nfc/util.hh:98:28: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
    static T *Create(const v8::Arguments &args);
                           ^~~~~~~~~~~~~
                           v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
../nfc/util.hh:100:28: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
    static T *Create(const v8::Arguments &args);
                           ^~~~~~~~~~~~~
                           v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
../nfc/util.hh:102:28: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
    static T *Create(const v8::Arguments &args);
                           ^~~~~~~~~~~~~
                           v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
../nfc/util.hh:106:44: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
    static v8::Handle<v8::Value> New(const v8::Arguments &args);
                                           ^~~~~~~~~~~~~
                                           v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:139:35: error: no member named 'NewSymbol' in 'v8::String'
    tpl->SetClassName(v8::String::NewSymbol(name));
                      ~~~~~~~~~~~~^
../nfc/util.ii:140:74: error: too few arguments to function call, expected 2, have 1
    T::constructor = v8::Persistent<v8::Function>::New(tpl->GetFunction());
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                   ^
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:639:3: note: 'New' declared here
  V8_INLINE static T* New(Isolate* isolate, T* that);
  ^
/Users/Stefan/.node-gyp/4.4.4/include/node/v8config.h:301:20: note: expanded from macro 'V8_INLINE'
# define V8_INLINE inline __attribute__((always_inline))
                   ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:141:30: error: no member named 'NewSymbol' in 'v8::String'
    exports->Set(v8::String::NewSymbol(name), T::constructor);
                 ~~~~~~~~~~~~^
../nfc/util.ii:148:31: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
  ObjectWrap<T>::Create(const v8::Arguments &args) {
                              ^~~~~~~~~~~~~
                              v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:149:13: error: member access into incomplete type 'const v8::internal::Arguments'
    if (args.Length() != 0) {
            ^
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:160:31: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
  ObjectWrap<T>::Create(const v8::Arguments &args) {
                              ^~~~~~~~~~~~~
                              v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:161:13: error: member access into incomplete type 'const v8::internal::Arguments'
    if (args.Length() != 1) {
            ^
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:164:39: error: type 'const v8::internal::Arguments' does not provide a subscript operator
    return new T(fromExternal<A0>(args[0]));
                                  ~~~~^~
../nfc/util.ii:172:31: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
  ObjectWrap<T>::Create(const v8::Arguments &args) {
                              ^~~~~~~~~~~~~
                              v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:173:13: error: member access into incomplete type 'const v8::internal::Arguments'
    if (args.Length() != 2) {
            ^
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:176:39: error: type 'const v8::internal::Arguments' does not provide a subscript operator
    return new T(fromExternal<A0>(args[0]),
                                  ~~~~^~
../nfc/util.ii:177:39: error: type 'const v8::internal::Arguments' does not provide a subscript operator
                 fromExternal<A1>(args[1]));
                                  ~~~~^~
../nfc/util.ii:192:28: error: no type named 'Arguments' in namespace 'v8'; did you mean 'v8::internal::Arguments'?
  ObjectWrap<T>::New(const v8::Arguments &args) {
                           ^~~~~~~~~~~~~
                           v8::internal::Arguments
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
In file included from ../nfc.cc:1:
In file included from ../nfc/context.hh:4:
In file included from ../nfc/util.hh:172:
../nfc/util.ii:195:14: error: member access into incomplete type 'const v8::internal::Arguments'
    if (!args.IsConstructCall()) {
             ^
/Users/Stefan/.node-gyp/4.4.4/include/node/v8.h:139:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/nfc/nfc.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Stefan/Projects/Forks/node-libnfc/src
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! node-libnfc@0.1.0 install: `( cd src && node-gyp rebuild ) && gulp`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-libnfc@0.1.0 install script '( cd src && node-gyp rebuild ) && gulp'.
npm ERR! This is most likely a problem with the node-libnfc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ( cd src && node-gyp rebuild ) && gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-libnfc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls node-libnfc
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Stefan/Projects/Forks/node-libnfc/npm-debug.log

After replacing the binding.gyp with your above code, (and installing nan) I'm getting:

> node-libnfc@0.1.0 install /Users/Stefan/Projects/Forks/node-libnfc
> ( cd src && node-gyp rebuild ) && gulp

make: *** No rule to make target `Release/obj.target/nfc/src/nfc.o', needed by `Release/nfc.node'.  Stop.
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Stefan/Projects/Forks/node-libnfc/src
gyp ERR! node -v v4.4.4
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.4.4
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! node-libnfc@0.1.0 install: `( cd src && node-gyp rebuild ) && gulp`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-libnfc@0.1.0 install script '( cd src && node-gyp rebuild ) && gulp'.
npm ERR! This is most likely a problem with the node-libnfc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ( cd src && node-gyp rebuild ) && gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-libnfc
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls node-libnfc
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Stefan/Projects/Forks/node-libnfc/npm-debug.log
jeroenvollenbrock commented 8 years ago

Are you sure you're on the right version of libnfc? Your log mentions 0.1.0 while we're currently on 0.3.1.

stefanpearson commented 8 years ago

Ah yes, that's very strange, for some reason the version I had cloned was old. I'm now able to install it! Thank you!

jeroenvollenbrock commented 8 years ago

Apparently, gyp does not include the default header and library paths on OSX. I'll make sure this gets fixed in a future version.

stefanpearson commented 8 years ago

Great. In the meantime, I'll fork this and make those changes so I can install via npm

jeroenvollenbrock commented 8 years ago

This has been fixed in version 0.3.2 (available on npm as of now) Even though this was probably caused by this issue: https://github.com/nodejs/node-gyp/issues/773, the earlier mentioned workarround has been implemented in node-nfc.