OpenNI 2 和 Visual Studio 2012 [英] OpenNI 2 and Visual Studio 2012

查看:19
本文介绍了OpenNI 2 和 Visual Studio 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了 OpenNI 2 SDK (www.openni.org),我正在尝试在 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. 创建一个新的 C++ Win32 控制台应用程序项目
  2. 转到Project>MyProject Properties,然后在Configuration Properties>VC++ 目录...
  3. C:\Program Files (x86)\OpenNI2\Redist\;添加到可执行目录
  4. C:\Program Files (x86)\OpenNI2\Include\;添加到包含目录
  5. C:\Program Files (x86)\OpenNI2\Redist\;添加到参考目录
  6. C:\Program Files (x86)\OpenNI2\Lib\;添加到库目录
  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

但是当我尝试构建时出现以下未解决的符号错误(其中 ConsoleApplication1 是我的项目名称)

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.

我也尝试了 64 位版本,创建了一个 64 位项目,但我有同样的错误.

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?

推荐答案

您还应该执行以下步骤:

Also you should do the below steps:

0-在 C/C++ 部分,在常规"节点下,选择

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

"Additional Include Directories" 

并添加

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

这些是指向 OpenNI Include 目录位置的环境变量.(默认为:

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-在链接器部分,在常规"节点下,选择

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

"Additional Library Directories" 

并添加

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

这些是指向 OpenNI Lib 目录位置的环境变量.(默认为:

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-在链接器部分,在输入节点下,选择

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

"Additional Dependencies" 

并添加

OpenNI2.lib or OpenNI2.lib

3- 确保将 Additional Include 和 Library 目录添加到 ReleaseDebug 配置中.

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

4-将 OpenNI 的 redist 目录中的所有文件(请参阅环境变量$(OPENNI2_REDIST)"或$(OPENNI2_REDIST64)")复制到您的工作目录.(默认为

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). 

请注意,从命令行运行时,工作目录是可执行文件所在的目录,而从 Visual Studio 运行的默认目录是项目文件(.vcproj、.vcxproj)所在的目录找到了.

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.

这篇关于OpenNI 2 和 Visual Studio 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆