如何摆脱这些编译器错误glu.h? [英] how do i get rid of these compiler errors in glu.h?

查看:1275
本文介绍了如何摆脱这些编译器错误glu.h?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在64位Windows 8上使用此教程(使用netbeans和cygwin) 4.8.1。



我得到许多错误,像这样:/usr/include/w32api/GL/glu.h:68:79:error:expected')'before '*'token。



在这样的语句上:void APIENTRY gluQuadricCallback(GLUquadric * qobj,GLenum which,void(CALLBACK * fn)());

错误消息上的指针指向fn()之前的*。



编辑:包括windef.h编译器错误消息。



我剩下一堆未定义的引用,如:glfwInit



edit2:using AndréFischer的想法,我可以得到一个干净的编译(你需要添加目录和-l选项的链接器)。



我现在有一个:跳过不兼容。 ./../../../../Windows/SysWOW64/opengl32.dll搜索-lopengl32和:未定义的引用`_ imp _vsnprintf'。所以它看起来像我有一个32/64位的问题和一个未定义的外部。



必须有一个更聪明的方式来获得opengl在窗口上工作。

解决方案

我假设你的意思是教程1:打开窗口,并使用Netbeans的内置构建系统而不是CMake。



包含头文件的顺序很重要()。尝试如下:

  #include< windef.h> //根据上面的注释
#include< GL / glew.h> // before any gl headers
#include< GL / gl.h>

//#include< GL / glext.h> // Linux headers
//#include< GL / wglext.h> // Windows headers - 不知道cygwin需要哪些。只是尝试它

#include< GL / glu.h> // Always after gl.h
#include< GL / glfw.h> //当所有gl标头都被包含时

在项目目录中创建一个名为include的目录。



GLFW下载站点,并将.dll / .so放入你的构建文件夹(或提取它们在某处,并将它们添加到搜索目录)文件到include / GL。



此外,教程中的glfw代码稍微过时;它不再与glfw3工作。
您必须使用GLFW的转换指南 /尝试更新此版本(我无法测试,因为我目前没有



最后下载 GLEW源,并按照README.txt中的说明进行构建。将.dll / .so文件夹(或添加到搜索目录)和头文件放入include / GL。



-Flags:

  -Iinclude / 

最后在链接器中添加以下参数:

  -L / lib -lglu32 -lopengl32  - lGL -lGLU -lglfw -lglew 

您现在应该能够编译教程。



编辑:添加了关于构建GLEW,GLFW的说明,并完成了我的回答,包括从头构建一切。

Edit2:Linked glfw3版本的教程代码。

Edit3:添加了缺少的链接器选项。


trying to use this tutorial on 64-bit windows 8 with netbeans and cygwin 4.8.1.

i get many errors like this: /usr/include/w32api/GL/glu.h:68:79: error: expected ‘)’ before ‘*’ token.

on statements like this: void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)());

the pointer on error message points to the * before the fn().

edit: including windef.h gets rid of the compiler error messages.

i am left with a bunch of undefined references like: glfwInit

edit2: using André Fischer's ideas, i can get a clean compile (you need to add the directory and a -l option for the linker).

i now have a: skipping incompatible ../../../../../Windows/SysWOW64/opengl32.dll when searching for -lopengl32 and: undefined reference to `_imp_vsnprintf'. so it looks like i have a 32/64 bit problems and an undefined external.

there must be a saner way to get opengl working on windows.

解决方案

I assume you mean Tutorial 1: Opening a Window and are using Netbeans' builtin build system instead of CMake.

The order in which you include the header files is important (source). Try it like this:

#include <windef.h> // According to comments above
#include <GL/glew.h> // Before any gl headers
#include <GL/gl.h>

//#include <GL/glext.h> // Linux headers
//#include <GL/wglext.h> // Windows headers - Not sure which ones cygwin needs. Just try it

#include <GL/glu.h> // Always after gl.h
#include <GL/glfw.h> // When all gl-headers have been included

Create a directory named "include" in your project directory with a subfolder "GL".

Grab the binaries (32 bit, MinGW) from the GLFW Download Site and put the .dll/.so into your build-folder (Or extract them somewhere and add them to the search directories) and the header files into "include/GL".

Also the glfw code in the tutorial is slightly outdated; It does not work with glfw3 anymore. You'll have to update it using GLFW's conversion guide/try this version (which I haven't been able to test, since I'm currently not at home) or use glfw2.

Finally download the GLEW sources and build it by following the instructions in the README.txt. Put the .dll/.so into your build-folder (or add to search directories) and the header files into "include/GL".

Add following to your Compiler-Flags:

-Iinclude/

Finally add following arguments to your Linker:

-L/lib -lglu32 -lopengl32 -lGL -lGLU -lglfw -lglew

You should be able to compile the tutorial now.

Edit: Added instructions for building GLEW, GLFW and completed my answer to include building everything from scratch.
Edit2: Linked glfw3-version of the tutorial-code.
Edit3: Added missing linker options.

这篇关于如何摆脱这些编译器错误glu.h?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆