'GLEWContext does not name a type' Ubuntu 上的错误
'GLEWContext does not name a type' error on ubuntu
我正在尝试将glew_mx项目从Windows移植到ubuntu,但由于GLEWContext未定义,我总是收到错误。
error: ‘GLEWContext’ does not name a type
我知道我真的不需要 linux 上的 GLEWContext,但我必须定义
GLEWContext* glewGetContext();
为了编译我的项目。所以我创建了一个全局 GLEWContext,并简单地在 glewGetContext 中返回它。
我的 window.h 代码如下所示:
#pragma once
#define GLEW_MX
#define GLEW_STATIC
#include "GL/glew.h"
#include "GLFW/glfw3.h"
#define GLM_SWIZZLE
#include "glm/glm.hpp"
#include "glm/ext.hpp"
#ifdef _WIN32
#define CONTEXT_PREFIX window
#else
#define CONTEXT_PREFIX
#endif
namespace window
{
class Window
{
public:
Window() {}
~Window() {}
//...
#ifdef _WIN32
static void makeContextCurrent(Window* window_handle);
#endif
static Window* createWindow(int win_width, int win_height, const std::string& title, GLFWmonitor* monitor, Window* share);
GLFWwindow* window;
#ifdef _WIN32
GLEWContext* glew_context;
#endif
//...
private:
//...
};
GLEWContext* glewGetContext();
#ifdef _WIN32
//...
#else
GLEWContext* glew_context;
#endif
}
窗口中的代码.cpp如下所示:
#ifdef _WIN32
GLEWContext* window::glewGetContext()
{
//...
}
#else
GLEWContext* window::glewGetContext()
{
return glew_context;
}
#endif
在窗口中编译最后两行时发生错误。非常感谢您的帮助
编译器似乎编译了您的Window
类并进入GLEWContext* glew_context
行。但GLEWContext
可能未定义,因此前向声明可能会有所帮助。
由于您要从Windows移植到ubuntu,因此必须确保编译器支持该#pragma
。您可以将包含保护更改为
#ifndef WINDOW_H
#define WINDOW_H
// Your code here
#endif
相关文章:
- 分段 Linux Ubuntu 中的 g++ 错误,但在 Windows 中的 g++/MingW 中,在 C++ 中打
- 这是 ubuntu 16.04 中的 gdb 错误吗?
- 链接器错误-在ubuntu中找不到CMake和Cuda 10.1的lcudart
- 为什么以下代码在在线 ide(gcc 7.2.0) 上有效,但在 ubuntu 上出现错误?
- 当有 icqdesktop 错误时如何编辑制作文件 (制作: *** [所有] 错误 2) Ubuntu 18.04 6
- Clang格式不使用.clang格式的文件ubuntu(没有错误)
- cmake cuda在Windows上单独的编译静态LIB链接错误,但在Ubuntu上没有
- Open AL 的函数在 ubuntu 中使用 g++ 编译时给出未定义引用的错误
- 在 Ubuntu 17.04 x64 下使用 SpiderMonkey (libmozjs-45.0.2) 的分段错误
- 在Boost标头文件中编译错误.Centos 7失败,在Ubuntu上编译16.04
- 如何在 Ubuntu 16.10 上使用柯南和 SDL2 解决未定义的引用错误?
- Ubuntu E:子进程 /usr/bin/dpkg 返回错误代码 (1)
- 在 Ubuntu 14.04 上构建 AWS c++ 配置库时出现"return type is incomplete"错误
- GRPC编译错误Protobuf 3.2.0(用旧版本的Protoc生成文件)Ubuntu 16.04
- 我正在尝试在Ubuntu 14上安装libgtk2.0-dev,但出现了一些错误
- 使用GCC v4.8在Ubuntu 14.04上定义C 11中元组向量时的编译错误
- 在Ubuntu 14.04启动我的应用程序时,非法说明(核心转储)错误,如何查看转储
- 将 Ubuntu 交叉编译到 Centos GLIBCXX 的错误
- Ubuntu上的启动ITK/VTK项目中的错误
- 'GLEWContext does not name a type' Ubuntu 上的错误