4

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.

Ray Tayek
  • 9,841
  • 8
  • 50
  • 90
  • Which bit of the tutorial? What does that line of glu.h say? – doctorlove Oct 05 '13 at 13:19
  • the first tutorial (tutorial01_first_window). the line says: void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)()); – Ray Tayek Oct 05 '13 at 13:21
  • 1
    I would be suspect of the pre-processor definition of `CALLBACK`. It's usually defined in a system header to define the default calling convention for callbacks, but if it is defined incorrectly this sort of thing happens. `windef.h` usually defines it is `__stdcall`. – Andon M. Coleman Oct 05 '13 at 13:47
  • including windef.h helps. please see edit. – Ray Tayek Oct 05 '13 at 14:05
  • So, now you miss the required library(s). And show the exact error messages (or some part, if they all look similar). – SChepurin Oct 05 '13 at 14:26
  • yes, undefined reference to `glfwInit'. the tutorial uses cmake and it has a lot of makefiles. one is for mingw that has a LIB = ../lib/win32/libglfw.a and a SOLIB = ../lib/win32/libglfwdll.a but i can not find any .dll or .a files. – Ray Tayek Oct 05 '13 at 14:41
  • i made some progress, see edit2 above. – Ray Tayek Oct 07 '13 at 07:15

1 Answers1

5

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.

  • i did most of what you suggest, but i still get compile errors from things like GLFW_WINDOW’ was not declared in this scope, ‘glfwEnable’ was not declared in this scope, too few arguments to function ‘void glfwSwapBuffers(GLFWwindow*)’ – Ray Tayek Oct 05 '13 at 21:46
  • This is most likely because you are trying to use glfw3 with the glfw2-api. **glfwEnable** is now **glfwSetInputMode**, **GLFW_WINDOW** was deprecated and is now removed, **glfwSwapBuffers** needs a pointer to the window you want to swap the buffers to. See [this creating a window guide for glfw3](http://www.glfw.org/documentation.html) for the new way to create a glfw window. For a complete list of all changes I suggest looking into the [conversion guide](http://www.glfw.org/docs/3.0/moving.html) I posted earlier. – André Fischer Oct 05 '13 at 22:00
  • I've linked to a modified version of the tutorial, which should work, in my answer. – André Fischer Oct 05 '13 at 22:13
  • the modified version compiles after a few conversion changes. i am now having problems getting netbeans to find the libraries. – Ray Tayek Oct 07 '13 at 00:33
  • having some luck using this post: http://stackoverflow.com/questions/14237915/setting-up-opengl-netbeans-project-with-glfw-on-ubuntu - now it finds the glfw3 and glew32 libraries. all need to do now is find and add the opengl library – Ray Tayek Oct 07 '13 at 07:01
  • Take a look at [this](http://www.cs.toronto.edu/~wongam/d18_cygwin_opengl_setup/cygwin_opengl_setup.html). You also have to add **-L/lib -lglu32 -lopengl32** to the linker options when using cygwin. Forgot to add that to my answer, sorry. – André Fischer Oct 07 '13 at 08:34
  • i am using: -L/cygdrive/D/dev/glfw-3.0.3.bin.WIN64/lib-mingw -L/cygdrive/D/dev/glew-1.10.0/lib/Release/x64 -L../../../../../Windows/SysWOW64 -lglfw3 -lglew32 -lopengl32, but i still that unresolved extern and it's not happy with the 64 bit lib :( – Ray Tayek Oct 07 '13 at 11:24