【问题标题】:NuiApi.h include failed in Visual Studio 2012 DLL projectNuiApi.h 在 Visual Studio 2012 DLL 项目中包含失败
【发布时间】:2013-10-22 20:05:23
【问题描述】:

我尝试制作使用我的 DLL 来处理 Kinect 的控制台应用程序。 当我构建我的项目时,我得到:

2>e:\projects\c++\vs\kinect dll\consoleapplication1\consoleapplication1.cpp(4): 警告 C4627: '#include "KinectDLL.h"': 查找预编译头使用时跳过 2> 将指令添加到“stdafx.h”或重建预编译头文件 2> e:\michał\projects\c++\vs\kinect dll\kinect dll\depthreader.h(4): 致命错误 C1083:无法打开包含文件:'NuiApi.h':没有这样的文件或目录

注意:ConsolApplication1 和 Kinect DLL 是同一个解决方案中的 2 个项目,第一个有一个依赖项 - Kinect DLL 项目作为 DLL。我在两个项目中都关闭了“使用预编译头文件”!

Kinect DLL 项目:

KinectDLL.h:

#ifdef KINECTDLL_EXPORTS
#define KINECTDLL_API __declspec(dllexport) 
#else
#define KINECTDLL_API __declspec(dllimport) 
#endif

DepthReader.h:

#pragma once
#include <ole2.h>
#include <Windows.h>
#include "NuiApi.h"
#include "KinectDLL.h"

namespace KinectDLL{

    class DepthReader{

        static KINECTDLL_API const int        depthWidth  = 640;
        static KINECTDLL_API const int        depthHeight = 480;
        static KINECTDLL_API const int        bytesPerPixel = 4;
    public:
        KINECTDLL_API DepthReader(void);
        KINECTDLL_API ~DepthReader(void);

        KINECTDLL_API int Run(HINSTANCE hInstance, int nCmdShow);
    private:
        HANDLE depthStreamHandle;
        HANDLE nextDepthFrameEvent;
        HANDLE depthStream;
        BYTE* depthRGBX;
        bool nearMode;
        INuiSensor* sensor;
        //HWND m_hWnd;
        HRESULT CreateFirstConnected();
        void Update();
        void ProcessDepth();
    };
}

DepthReader.cpp

#include "stdafx.h"
#include "DepthReader.h"
namespace KinectDLL{
    DepthReader::DepthReader(void) :
        nextDepthFrameEvent(INVALID_HANDLE_VALUE),
        depthStreamHandle(INVALID_HANDLE_VALUE),
        nearMode(false),
        sensor(NULL)
    {
        // create heap storage for depth pixel data in RGBX format
        depthRGBX = new BYTE[depthWidth*depthHeight*bytesPerPixel];
    }

...等等,主要是从 MS Kinect 示例中复制和粘贴...

Consoleapplication1 项目:

Consolapplication1.cpp:

#include "KinectDLL.h"
#include "stdafx.h"
#include "Rotations.h"
#include "Camera.h"
#include "FileLoader.h"
#include "DepthReader.h"

using namespace std;

Camera camera;
Rotations rotations;
FileLoader fileLoader;
KinectDLL::DepthReader depthReader;

... 然后是 OpenGL,来自文件的点。我使用 Kinect 来控制场景,而不是显示其中的数据。暂时没有 depthReader。

很明显,我在做某事愚蠢,但我看不到什么。我正在阅读有关 VC++ 中 DLL 的 Microsoft 示例,但我看不出有什么问题。

【问题讨论】:

    标签: c++ visual-studio-2012 dll include kinect


    【解决方案1】:

    我刚刚创建了一个 dll,其中包含一些依赖于 kinect 骨架流的函数。我所做的是这样的:

    #ifdef KINECTFUNCTIONSDLL_EXPORTS
    #define KINECTFUNCTIONSDLL_API __declspec(dllexport) 
    #else
    #define KINECTFUNCTIONSDLL_API __declspec(dllimport)  
    #endif
    
    
    #include <Windows.h>
    #include <NuiApi.h>
    using namespace std;
    #include <string>
    namespace KinectFunctions{
    
        class GestureRecognizer
    {
    
     public:
      Vector4 KINECTFUNCTIONSDLL_API resta(Vector4 vector1,Vector4 vector2);
     }
    }
    

    现在是 .cpp:

    #include "KinectFunctionsDLL.h"
    #define _USE_MATH_DEFINES
    #include <math.h>
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    namespace KinectFunctions{
    
    Vector4 GestureRecognizer::resta(Vector4 vector1,Vector4 vector2){
     Vector4 salida;
     salida.x=vector1.x-vector2.x;
     salida.y=vector1.y-vector2.y;
     salida.z=vector1.z-vector2.z;
     return salida;
     }
    

    }

    请记住,必须在创建用于创建 dll 的项目时检查 DLL 选项(当您选择创建新项目时会出现一个复选框。如下所示: https://www.youtube.com/watch?v=yEqRyQhhto8

    当然,您需要添加 kinect dll、kinect10.lib 和头文件的依赖项,就像在您要使用设备的任何项目中一样。

    【讨论】:

      猜你喜欢
      • 2016-06-08
      • 1970-01-01
      • 2018-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      相关资源
      最近更新 更多