Opengl 设置GLEW+;代码块

Opengl 设置GLEW+;代码块,opengl,codeblocks,glew,Opengl,Codeblocks,Glew,我想让GLEW与代码块一起工作,并一直在尝试获取 屏幕上显示的第一种方法开始工作。 这是将glew静态编译到可执行文件中的方法。但我还没有成功地将其正确编译。 我在一台Windows7电脑上运行代码块10.05 这就是我到目前为止所做的: 已下载GLEW 1.7.0 取消压缩到C: 在代码块中创建空项目 将glew.h、wglew.h和glew.c移动到我的项目源目录中 将这三个文件全部添加到项目中 更改了glew.h和wglew.h在glew.c中的包含路径 #include <GL/

我想让GLEW与代码块一起工作,并一直在尝试获取
屏幕上显示的第一种方法开始工作。
这是将glew静态编译到可执行文件中的方法。
但我还没有成功地将其正确编译。
我在一台Windows7电脑上运行代码块10.05

这就是我到目前为止所做的:

  • 已下载GLEW 1.7.0
  • 取消压缩到C:
  • 在代码块中创建空项目
  • 将glew.h、wglew.h和glew.c移动到我的项目源目录中
  • 将这三个文件全部添加到项目中
  • 更改了glew.h和wglew.h在glew.c中的包含路径

    #include <GL/glew.h> 
    #include <GL/wglew.h>
    
  • 使用以下代码创建了一个简单的主文件

    #define GLEW_STATIC
    #include "glew.h"
    
    int main() {
        glewInit();
        return 0;
    }
    
这样一来,汇编将产生大量警告 和错误

  • 错误,例如:

    glew.c|2933|undefined reference to `wglGetProcAddress@4'|
    glew.c|2934|undefined reference to `wglGetProcAddress@4'|
    glew.c|2935|undefined reference to `wglGetProcAddress@4'|
    glew.c|2936|undefined reference to `wglGetProcAddress@4'|
    
    glew.c|10050|warning: '__wglewReleaseVideoCaptureDeviceNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10052|warning: '__wglewBindVideoImageNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10053|warning: '__wglewGetVideoDeviceNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10054|warning: '__wglewGetVideoInfoNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10055|warning: '__wglewReleaseVideoDeviceNV' redeclared without dllimport attribute: previous dllimport ignored|
    
  • 警告,例如:

    glew.c|2933|undefined reference to `wglGetProcAddress@4'|
    glew.c|2934|undefined reference to `wglGetProcAddress@4'|
    glew.c|2935|undefined reference to `wglGetProcAddress@4'|
    glew.c|2936|undefined reference to `wglGetProcAddress@4'|
    
    glew.c|10050|warning: '__wglewReleaseVideoCaptureDeviceNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10052|warning: '__wglewBindVideoImageNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10053|warning: '__wglewGetVideoDeviceNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10054|warning: '__wglewGetVideoInfoNV' redeclared without dllimport attribute: previous dllimport ignored|
    glew.c|10055|warning: '__wglewReleaseVideoDeviceNV' redeclared without dllimport attribute: previous dllimport ignored|
    
我哪里出错了?

如果有必要,我很乐意分享更多信息

您可以通过使用
opengl32
链接程序来消除这些错误,也可以通过在
\include
s之前的GLEW.c中定义
GLEW\u STATIC
来消除这些警告


在任何情况下,您的程序都无法工作,因为在使用
glewInit
之前,您需要有一个有效的OpenGL上下文。您需要使用glut/glfw/SDL/wglCreateContext/etc创建一个。您可以通过将程序链接到
opengl32
来消除这些错误,并通过在
\include
s之前在GLEW.c中定义
GLEW\u STATIC
来消除这些警告

在任何情况下,您的程序都无法工作,因为在使用
glewInit
之前,您需要有一个有效的OpenGL上下文。您需要使用glut/glfw/SDL/wglCreateContext/etc创建一个