为 GFLW 编写 C++/CLI 包装器
Writing a C++/CLI wrapper for GFLW
我正在尝试为 GLFW 编写一个 C++/CLI 包装器。我创建了一个名为 GLFWWrapper 的 CLR 类库项目,并将glfw3.lib
添加到其他依赖项,并将头文件文件夹添加到其他包含目录中。
到目前为止,我的GLFWWrapper.h看起来像这样:
// GLFWWrapper.h
#pragma once
#include <GLFWglfw3.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:未解析的 typeref 令牌 (0100000B) for 'GLFWmonitor';映像可能无法运行
它们在我的上下文中意味着什么,这会有问题吗?
添加:
struct GLFWwindow {};
struct GLFWmonitor {};
之前:
#include <GLFW/glfw3.h>
这至少会消除警告。我没有设置验证它是否会正确执行,但我认为这对您和需要做您正在做的事情的任何其他人来说都很容易做到。
相关文章:
- 如何为要在 C# 中使用的静态库创建 C++ 或 C++/CLI 包装器
- 无法使用c++/cli包装从c#dll加载函数
- 使用 C++/CLI 包装器将 2D 数组从 C# 传递到非托管C++
- Visual Studio:C++\CLI 包装程序集路径依赖性问题
- C++/CLI 包装器不能使用来自本机C++ dll 的矢量
- 使用C /CLI包装器DLL时缺少功能
- C# 中与 CLI 包装器通信C++未处理的异常
- 访问 C++/CLI 包装器中的私有C++方法
- 将 C# 委托传递给 C++/CLI 包装器
- 为 GFLW 编写 C++/CLI 包装器
- C++/CLI 包装器LNK2028和LNK2019错误
- 指针成员的 C++/CLI 包装器 - C++ 单例实例
- 指向指针 C++/CLI 包装器的指针
- 从 CLI 包装器检索本机对象
- C++/CLI 包装器,供本机C++用作 C# 中的参考
- 如何用C++/CLI包装C++类
- 从C++/CLI包装返回指向非托管类的指针,该类可以导入C#
- 如何使用C++/CLI包装器将变量参数从托管传递到非托管
- 调用Caffe的c++ /CLI包装器时的AccessViolationException
- 正在取消本机C++循环的C++/CLI包装中的BackgroundWorker