viewport to gl coordinates

I’m trying to convert the viewport coordinates of a mouse click to opengl coordinates, following this article: http://nehe.gamedev.net/data/articles/article.asp?article=13
here is my code:

[C++ Error] gl.h(1152): E2141 Declaration syntax error
[C++ Error] gl.h(1153): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1152): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1153): E2141 Declaration syntax error
[C++ Error] gl.h(1154): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1153): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1154): E2141 Declaration syntax error
[C++ Error] gl.h(1155): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1154): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1155): E2141 Declaration syntax error
[C++ Error] gl.h(1156): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1155): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1156): E2141 Declaration syntax error
[C++ Error] gl.h(1157): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1156): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1157): E2141 Declaration syntax error
[C++ Error] gl.h(1158): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1157): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1158): E2141 Declaration syntax error
[C++ Error] gl.h(1159): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1158): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1159): E2141 Declaration syntax error
[C++ Error] gl.h(1160): E2238 Multiple declaration for ‘WINGDIAPI’
[C++ Error] gl.h(1159): E2344 Earlier declaration of ‘WINGDIAPI’
[C++ Error] gl.h(1160): E2141 Declaration syntax error
[C++ Error] gl.h(1160): E2228 Too many error or warning messages

What am I doing wrong ?

You need to add #include <windows.h> before you include <gl/gl.h>

If you do this (and eliminate other potentional errors) you will probably end up with linker errors: “unresolved external symbol” - since you use gl.h and glu.h you will need to add opengl32.lib and glu32.lib in your project’s linker settings.