设置GLEW + CodeBlocks

时间:2012-06-18 00:23:21

标签: opengl codeblocks glew

我想让GLEW与CodeBlocks一起工作并一直试图获得 site上提出的第一种方法 这是将glew静态编译成可执行文件的方法。
但是我没有设法把它弄好 我在运行CodeBlocks 10.05的PC上运行Windows 7。

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

  • 已下载GLEW 1.7.0
  • Unziped to C:
  • 在CodeBlocks中创建空项目
  • 将glew.h,wglew.h和glew.c移至我的项目源目录
  • 将所有三个文件添加到项目中
  • 在glew.c中为glew.h和wglew.h更改了包含路径

    #include <GL/glew.h> 
    #include <GL/wglew.h>
    

    #include "glew.h"
    #include "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|
    

我哪里出错?
如有必要,我很乐意分享更多信息!

1 个答案:

答案 0 :(得分:4)

您可以通过在opengl32之前的glew.c中定义GLEW_STATIC来将您的程序与#include以及这些警告相关联来消除这些错误。

在任何情况下,您的程序都无法运行,因为您需要拥有有效的OpenGL上下文才能使用glewInit。你需要用glut / glfw / SDL / wglCreateContext /等创建一个。