OpenNI 2 and Visual Studio 2012
Asked Answered
S

3

9

I just downloaded OpenNI 2 SDK (www.openni.org) and I am trying to setup a project in Visual Studio 2012. What I did:

  1. Create a new C++ Win32 Console Application Project
  2. Go to Project>MyProject Properties and, in Configuration Properties>VC++ Directories...
  3. Added C:\Program Files (x86)\OpenNI2\Redist\; to Executable Directories
  4. Added C:\Program Files (x86)\OpenNI2\Include\; to Include Directories
  5. Added C:\Program Files (x86)\OpenNI2\Redist\; to Reference Directories
  6. Added C:\Program Files (x86)\OpenNI2\Lib\; to Library Directories

But when I try to build I have the following unresolved symbol error (where ConsoleApplication1 is my project's name)

Error   1   error LNK2019: unresolved external symbol
__imp__oniInitialize referenced in function
"public: static enum openni::Status __cdecl openni::OpenNI::initialize(void)"
(?initialize@OpenNI@openni@@SA?AW4Status@2@XZ)
c:\Users\MyPC\documents\visual studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj
ConsoleApplication1

I know this linking error is saying that the linker can't find some libraries but I thought what I just did was enough.

I also tried the 64 bit version, creating a 64 bit project, but I have the same errors.

I couldn't find satisfying documentation on this topic.

I'm sure I'm missing something silly. Can you please give some advice on this?

Seaborne answered 1/2, 2013 at 10:24 Comment(0)
D
7

Also you should do the below steps:

0-In the C/C++ section, under the "General" node, select

"Additional Include Directories" 

and add

"$(OPENNI2_INCLUDE)" (if you use the 32-bit version) or 
"$(OPENNI2_INCLUDE64)" (if you use the 64-bit version). 

These are environment variables that point to the location of the OpenNI Include directory. (The defaults are :

C:\Program Files\OpenNI2\Include or 
C:\Program Files (x86)\OpenNI2\Include)

1-In the Linker section, under the "General" node, select

"Additional Library Directories" 

and add

"$(OPENNI2_LIB)" (if you use the 32-bit version) or 
"$(OPENNI2_LIB64)" (if you use the 64-bit version). 

These are environment variables that point to the location of the OpenNI Lib directory. (The defaults are:

C:\Program Files\OpenNI2\Lib or 
C:\Program Files (x86)\OpenNI2\Lib)

2-In the Linker section, under the input node, select

"Additional Dependencies" 

and add

OpenNI2.lib or OpenNI2.lib

3-Ensure that you add the Additional Include and Library directories to both your Release and Debug configurations.

4-Copy all the files from OpenNI's redist directory (see environment variable "$(OPENNI2_REDIST)" or "$(OPENNI2_REDIST64)") to your working directory. (The defaults are

C:\Program Files\OpenNI2\Redist or 
C:\Program Files (x86)\OpenNI2\Redist). 

Be aware that when you run from command line, the working directory is the directory where the executable can be found, and where you run from Visual Studio the default directory is where the project file (.vcproj, .vcxproj) can be found.

Deb answered 25/2, 2013 at 23:22 Comment(2)
Hi NKN, before I post any new question, do you have any idea why the ASUS Xtion just works whilst the Microsoft Kinect camera is not recognized? Thanks.Seaborne
I had any experiment with ASUS Xtion, sorry.Deb
R
1

you also need to point to the actual library file: openni2.lib

Risorgimento answered 8/2, 2013 at 23:7 Comment(1)
but that's inside the OpenNI2/Lib folderSeaborne
M
1

If you add all of options (Include, Lib, ...) to your project setting and again get this error, maybe your project platform is Win32 and you want to use OpenNI x64

In this case, you must change the platform to x64 (Project properties at the top of the page)

  • If you don't have x64 option, make a new one ;)
Molybdenous answered 23/7, 2014 at 12:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.