OpenNI2 出现链接错误的问题

    今天下个OpenNI2来玩,本地环境win8 64位, vs2010。来到OpenNI官网,心想,咱的机器是64的,下载OpenNI2 64位的那是必须的(刘大脑袋的语气),大概1分钟,下载好了,把相应的环境配置好,按照官网的配置就可以,也就是设置头文件目录,库文件目录,再把相应的lib文件加到工程中。步骤如下:

Visual Studio

  1. Open a new project or an existing one with which you want to use OpenNI
  2. In the Visual Studio menu, open the Project menu and choose Project Properties.
  3. 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)
  4. 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)
  5. In the Linker section, under the input node, select ”Additional Dependencies” and add OpenNI2.lib or OpenNI2.lib
  6. Ensure that you add the Additional Include and Library directories to both your Release and Debug configurations.
  7. 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.

然后,写了个测试程序

#include 

int main()
{
    openni::Status status = openni::OpenNI::initialize();
    if (status != openni::STATUS_OK)
    {
        return -1;
    }

    openni::OpenNI::shutdown();

    return 0;
}

这么简单的代码,本以为F7之后,就会顺利的出现

========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

但是,尼玛,竟然出现的是

1>main.obj : 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)
1>main.obj : error LNK2019: unresolved external symbol __imp__oniShutdown referenced in function "public: static void __cdecl openni::OpenNI::shutdown(void)" (?shutdown@OpenNI@openni@@SAXXZ)

坑爹啊~~~再仔细看了看加入的lib,没错啊,就是openni2.lib啊~~~~一阵的谷歌,也有别人出现类似的问题,但是,也没找到答案~~~~这让老夫如何是好~~~纠结了半天,到Openni的社区里面再搜搜,看看有没有人遇到类似的情况,果然找到了~~~

坑爹的,竟然是因为我的vs2010是32位的,所以,Openni2也应该下32位的,我又把之前的64删除了,再下了个32的,成功解决。

转载于:https://www.cnblogs.com/tszhao/archive/2013/05/05/3061189.html

你可能感兴趣的:(OpenNI2 出现链接错误的问题)