Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenNI 2 and Visual Studio 2012

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?

like image 294
SteakOverflow Avatar asked Feb 01 '13 10:02

SteakOverflow


2 Answers

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.

like image 176
NKN Avatar answered Oct 17 '22 05:10

NKN


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

like image 29
Eran W Avatar answered Oct 17 '22 04:10

Eran W