【问题标题】:Writing a C++/CLI wrapper for GFLW为 GFLW 编写 C++/CLI 包装器
【发布时间】:2016-08-15 02:01:26
【问题描述】:

我正在尝试为 GLFW 编写 C++/CLI 包装器。我创建了一个名为 GLFWWrapper 的 CLR 类库项目,并将 glfw3.lib 添加到 Additional Dependencies,并将头文件文件夹添加到 Additional Include Directories。

到目前为止,我的 GLFWWrapper.h 看起来像这样:

// GLFWWrapper.h

#pragma once

#include <GLFW\glfw3.h>

using namespace System;

namespace GLFWWrapper {

    public ref class Window
    {
    public:
        Window(int width, int height, char * title);
    private:
        GLFWwindow * m_ptr;
    };
}

我的 GLFWWrapper.cpp 看起来像这样:

// This is the main DLL file.

#include "stdafx.h"

#include "GLFWWrapper.h"

namespace GLFWWrapper {

    Window::Window(int width, int height, char * title) {
        if (glfwInit() != GL_TRUE) {

        }
        else {
            m_ptr = glfwCreateWindow(width, height, title, nullptr, nullptr);
        }
    }
}

现在当我尝试编译它时,我收到以下警告:

GLFWWrapper.obj:警告 LNK4248:'GLFWwindow' 的未解析 typeref 令牌 (01000008);图像可能无法运行
GLFWWrapper.obj:警告 LNK4248:“GLFWmonitor”的未解析类型引用令牌(0100000B);图像可能无法运行

它们在我的上下文中是什么意思,这可能有问题吗?

【问题讨论】:

    标签: c# c++ glfw


    【解决方案1】:

    添加:

    struct GLFWwindow {};
    struct GLFWmonitor {};
    

    之前:

    #include <GLFW/glfw3.h>
    

    这至少会消除警告。我没有准备好验证它是否会正确执行,但我认为这对你和其他任何需要做你正在做的事情的人来说都很容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-03
      • 1970-01-01
      • 2011-07-19
      • 2016-12-29
      相关资源
      最近更新 更多