trying to use this tutorial on 64-bit windows 8 with netbeans and cygwin 4.8.1.
尝试在64位Windows 8上使用netbeans和cygwin 4.8.1使用本教程。
i get many errors like this: /usr/include/w32api/GL/glu.h:68:79: error: expected ‘)’ before ‘*’ token.
我得到很多这样的错误:/usr/include/w32api/GL/glu.h:68:79:错误:预期')'在'*'标记之前。
on statements like this: void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)());
像这样的语句:void APIENTRY gluQuadricCallback(GLUquadric * qobj,GLenum which,void(CALLBACK * fn)());
the pointer on error message points to the * before the fn().
错误消息上的指针指向fn()之前的*。
edit: including windef.h gets rid of the compiler error messages.
编辑:包括windef.h摆脱编译器错误消息。
i am left with a bunch of undefined references like: glfwInit
我留下了一堆未定义的引用,如: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).
edit2:使用AndréFischer的想法,我可以得到一个干净的编译(你需要为链接器添加目录和-l选项)。
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.
我现在有一个:跳过不兼容的../../../../../Windows/SysWOW64/opengl32.dll,当搜索-lopengl32和:未定义的引用`_imp_vsnprintf'。所以看起来我有一个32/64位问题和一个未定义的外部。
there must be a saner way to get opengl working on windows.
必须有一个更健全的方式让opengl在Windows上工作。
1 个解决方案
#1
3
I assume you mean Tutorial 1: Opening a Window and are using Netbeans' builtin build system instead of CMake.
我假设你的意思是教程1:打开一个窗口,并使用Netbeans的内置构建系统而不是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".
使用子文件夹“GL”在项目目录中创建名为“include”的目录。
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".
从GLFW下载站点获取二进制文件(32位,MinGW)并将.dll / .so放入您的构建文件夹(或者将它们解压缩并添加到搜索目录中)并将头文件添加到“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.
此外,教程中的glfw代码稍微过时了;它不再适用于glfw3。您必须使用GLFW的转换指南更新它/尝试此版本(我无法测试,因为我目前不在家)或使用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".
最后,按照README.txt中的说明下载GLEW源并构建它。将.dll / .so放入构建文件夹(或添加到搜索目录),将头文件放入“include / GL”。
Add following to your Compiler-Flags:
将以下内容添加到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.
编辑:添加了构建GLEW,GLFW的说明,并完成了我的答案,包括从头开始构建所有内容。 Edit2:链接的glfw3-版本的教程代码。 Edit3:添加了缺少的链接器选项。
#1
3
I assume you mean Tutorial 1: Opening a Window and are using Netbeans' builtin build system instead of CMake.
我假设你的意思是教程1:打开一个窗口,并使用Netbeans的内置构建系统而不是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".
使用子文件夹“GL”在项目目录中创建名为“include”的目录。
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".
从GLFW下载站点获取二进制文件(32位,MinGW)并将.dll / .so放入您的构建文件夹(或者将它们解压缩并添加到搜索目录中)并将头文件添加到“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.
此外,教程中的glfw代码稍微过时了;它不再适用于glfw3。您必须使用GLFW的转换指南更新它/尝试此版本(我无法测试,因为我目前不在家)或使用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".
最后,按照README.txt中的说明下载GLEW源并构建它。将.dll / .so放入构建文件夹(或添加到搜索目录),将头文件放入“include / GL”。
Add following to your Compiler-Flags:
将以下内容添加到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.
编辑:添加了构建GLEW,GLFW的说明,并完成了我的答案,包括从头开始构建所有内容。 Edit2:链接的glfw3-版本的教程代码。 Edit3:添加了缺少的链接器选项。