bengfarrell / nuimotion

Node.js wrapper for OpenNI/NiTE offering skeletal joint tracking and gestures
http://www.sweatintotheweb.com/nuimotion-for-node-js/
MIT License
74 stars 19 forks source link

Help building on ubuntu 12.04 #4

Closed KevinGrandon closed 11 years ago

KevinGrandon commented 11 years ago

Hi bengfarrell, I'm now trying to build on Ubuntu (12.04, 64-bit), and running into a few issues. Wondering if you could help me debug this.

Dir structure:

~/project/OpenNI2/ (From OpenNI2.2 redist folder after running install.sh)
~/project/NiTe2/ (From Nite2.2 redist folder after running install.sh)
~/project/node_modules/nuimotion/

Errors seen:

  CXX(target) Release/obj.target/nuimotion/src/Main.o
  CXX(target) Release/obj.target/nuimotion/src/enums/EnumMapping.o
  CXX(target) Release/obj.target/nuimotion/src/gestures/GestureRecognizer.o
  CXX(target) Release/obj.target/nuimotion/src/gestures/Swipe.o
  CXX(target) Release/obj.target/nuimotion/src/gestures/Wave.o
  SOLINK_MODULE(target) Release/obj.target/nuimotion.node
/usr/bin/ld: cannot find -lOpenNI2
/usr/bin/ld: cannot find -lNiTE2
collect2: ld returned 1 exit status
make: *** [Release/obj.target/nuimotion.node] Error 1
make: Leaving directory `/home/kevin/project/node_modules/nuimotion/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.5.0-23-generic
gyp ERR! command "node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/kevin/project/node_modules/nuimotion
gyp ERR! node -v v0.10.11
gyp ERR! node-gyp -v v0.10.0
gyp ERR! not ok 

Let me know if there's anything else I can provide. Unfortunately I'm not too familiar with building node addons, but I'll try to dig into the source a bit!

bengfarrell commented 11 years ago

Sure, hope I can help! So you're the same one that just reported that you couldn't build on OSX right?

Basically - the part that's confusing on this is linking the libraries that come with OpenNI/NiTE. It seems to be different on various platforms.

On Ubuntu, as you're talking about - I believe things should work as is. I'm not sure if you had changed the binding.gyp file when I was explaining how things are different on Windows/Mac.

To walk you through the binding.gyp file:

{ "conditions": [ [ "OS=='win'", { "variables": {

Set the linker location, no extra linking needed, just link backwards one directory

                "ONI_Root%": "../"
            }
        }, { # 'OS!="win"'
            "variables": {
                # Set the linker location, the -l flag is fine on Linux with no filepath
                # However, we need the additional option -rpath for dynamic linking
                "ONI_Root%": "",
            }
        }
    ]
],

That first condition applies to Windows as I've found. Though I don't have a Mac, I believe that this first condition applies on OSX as well. The condition creates an "ONI_ROOT" variable (I've named it) to relatively link to the root where your OpenNI libraries are stored.

For some reason, on Windows vs Linux, this is actually important. And in my experience it's been a little finicky where it links from.

I say "for some reason", because on Linux, it appears to not actually care. It just needs to create the dynamic linkage regardless of whether the files (.so library files) exist or not at build time. Therefore, I've created that other condition for non-Windows environments where ONI_ROOT is an empty string. This appears to make it not need to actively look for the library when building the add on - and doesn't raise any complaints.

Unfortunately, only Windows and Linux are accounted for here - Mac...again, I just can't test.

Your problem specifically - if you haven't changed the binding file, I'm not sure. However - as you DID ask about OSX previously, you may have tried changing that binding.gyp file when I was answering your question about OSX. If I do this, and set ONI_Root to that relative path: "../" on Linux, my build process does exactly as yours does. It fails to find the linked files in exactly the same path, and errors out the build process in the exact same way.

So - this could be easy to solve. Perhaps you just need to restore your binding.gyp file? Perhaps you had copied it over from your Mac after altering it?

Hope that helps! I may have to consider that I've installed OpenNI somewhere and set up an environmental variable on my system that makes it OK when I build on my system, but I don't think that's the case - I can't find anything!

KevinGrandon commented 11 years ago

Thanks for the extremely detailed explanation. I am trying from a clean ubuntu install, and an unmodified binding.gyp file. Still no dice. I'm going to close this out as I don't want to pollute your issues :)

I'll dig in and try to find something more concrete - I really want to use your library.

Thanks!

bengfarrell commented 11 years ago

No problem - I really spent a good deal of time on this kind of issue specifically with linked libraries, so I'm not psyched to hear that there might be other issues.

I appreciate you keeping at it - please do let me know if you find out the cause, I'd really love to document it for other folks.

thanks!