GLUT and macro redefinition errors

Hello, I hope this post is in the right section. I’ve just been trying to get GLUT working with Pelles C using the example code at http://www.trajectorylabs.com/getting_started_with_opengl_glut.html

This is my second attempt at getting GLUT to work after being totally baffled the first time a while back, and not managing to solve the problem by inquiring on the Pelles C forum, which to compound the problem I can’t even access at the moment for some reason!

Upon compiling I get just the following two errors:
Building myfirst.obj.
C:\Program Files\PellesC\Include\gl\glut.h(19): error #1050: Macro redefinition of ‘APIENTRY’.
C:\Program Files\PellesC\Include\gl\glut.h(20): error #1050: Macro redefinition of ‘CALLBACK’.
*** Error code: 1 ***

As far as I can see, I have put all the right files in the right places and ticked the right boxes in the project options (e.g. allow microsoft extensions), and after searching the web for F.A.Q.s I can’t find the above errors being addressed. I should stress that although being able to program some C I’m no expert at all this stuff so I could still be doing something stupid I guess.

Any thoughts? Thanks very much.

Andy

Macro redefinition of ‘APIENTRY’.
: it looks like you have #include of other things before glut. glut.h should (almost) be the only include.

Hmm, I’ve just got the following (full code is in the link I posted)

#include <windows.h>
#include <gl\gl.h>
#include <gl\glut.h>

Then it goes on to prototypes.

So there’s not much to go wrong with. I’ve tried selectively taking each one out to see what happens. Unsurprisingly it tells me to “imporve myself” after casuing more than 100 errors! :wink:

This is really frustrating, I haven’t even made OpenGL draw a box yet!

Could it be something to do with Windows Vista?

Not Vista, it is more your tool chain that needs some tweaking.
compiler/IDE/libs ?

For simple beginner stuff I found dev-c++ is really great, as you can even get sample code projects for OpenGL win win32, with glut, SDL, whatever, directly from the IDE itself.

Tweaking the compiler and libraries and stuff… oh dear, not one of my strong points! I’m playing round with various project options at the moment but frankly I don’t really know what I’m doing.

Here’s a thought: if I uninstall PellesC and then reinstall, then redownload the appropriate GLUT files - can there be anything that I’d have to change… surely it should work…

then don’t waste time :
http://www.bloodshed.net/dev/devcpp.html

Within Dev-C++, in menu Tools, Check for updates/packages, then community packs or something. I recommend the freeglut examples (modern opensource GLUT).
Then File, new project, multimedia tab, freeglut. F9. It works.

Ok ZbufferR, I’ll give it a try… although I’ll need to learn C++, but that was always going to be necessary eventually, trundling along as I am with plain old C.

No worries, despite its name, in fact Dev-C++ let you choose between C or C++, for each project.

Only problem with Dev-C++ is that it’s, well, dead.

Code::Blocks is a more modern effort, by one of the original developers of Dev-C++.

Ok, cheers Stephen.

Ok then, next problem that I have no idea of the source of…

I downloaded CodeBlocks (or should I say Code::Blocks) (the version with MINGW compiler) and opened a new OpenGL application project. Then I pasted the code from this OpenGL tutorial (http://www.gmonline.demon.co.uk/cscene/CS5/CS5-03.html) which is the same code I was trying to get working in PellesC and built the project. However, it doesn’t build, it says:

Switching to target: default
Compiling: main.cpp
mingw32-g++.exe: installation problem, cannot exec `cc1plus’: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

which to me doesn’t look like a problem with the code. But what do I know. Maybe there was something else (containing cc1plus) that I should have downloaded?

Any suggestions?

Well even is Dev-C++ is not maintained anymore, at least it works out of the box, that is not the case of all IDEs apparently … :smiley:

Tomorrow I shall try it in Dev-C++ (I can only hack mucking about with one new IDE per night) but only so long as a war doesn’t break out between the supporters of each one. :stuck_out_tongue:

To be fair, as an absolute beginner in OpenGL my needs will be very simple for now as far as IDEs are concerned.

Nah, I am just stuffing posts, so the number goes above nexusone with 2096 :smiley:

Edit: re-read your post. Maybe try updating to the latest version, found in the forums? The one with mingw bundled is over two years old. Now that you have the compiler, it should be simple to upgrade. Alternatively, search http://mingw.org for the missing file.

True, downloading Dev-C++ might save you some hassle, but it’s buggy and it uses an old version of MingW. And in any case, it’s a good idea to learn how to setup the compiler toolchain - it’s depressing how many people call themselves programmers and don’t even know the difference between an IDE and a compiler (e.g. “I use the Visual Studio compiler”, ugh!)

Righty then, I’m back for more punishment. ZbuffeR, I downloaded Dev-C++, and updated with the freeglut file. However, it doesn’t compile and complains that:

15 C:\Dev-Cpp\main01.cpp GL/glut.h: No such file or directory.

So, obviously it can’t find GLUT. So, can I ask what exactly do I do to let it find it. I can see a few places in the compiler options which look like I could add some kind of path to but I don’t know EXACTLY what to do… help!

Hehehe…Reminds me of 3rd year at uni. We had people trying run their source code when the moved onto a Linux system from Windows.

As for AndyCav’s problem, sorry never used Dev-c++, but I wonder what the point is in trying to get this to work…If you can’t solve problems like this then what are you actually going to write? Not very helpful I know, but…

–Stu!

Edit: So at least there is some useful content. Another option is to install cygwin and compile all this from the command line using good old gcc/g++. Then you have total control (so -I <inc path> to tell it where to get header files etc.)

I then use Eclipse for my IDE (with the vi plugin 8-), svn for version control and autoconf for build/packaging.

Did you install the relevant ‘Community Packages’ ?
How to do this :
http://molhanec.net/devcpphelp/packages.php

The packages you will probably need :

  • freeglut (opensource GLUT, should solve your glut.h problem)
  • sdl

Not sure if these are in, search for matching strings :

  • glew
  • glfw
  • opengl
  • everything gl :smiley:

Well, I just updated Dev-C++ with the package “glut” and that appears to have solved it for Dev-C++; I have spinning cones and spheres on the screen. Cheers for the help.

Stu, I know what you mean but then where do I start?! I mean I want to start learning OpenGL, but first I have to get something working so I can even just run the example code you find in tutorials and the like - and I couldn’t even get that running so I couldn’t even start learning. It’s a catch-22.

Was anyway. It’s all a bit complicated if you don’t already know exactly how this stuff works. For example - I just finally got the freeglut thing to work after being advised to dowload it, but I didn’t know (as silly as it may seem) that you also have to download another package just called “glut”. It wasn’t obvious to a beginner.

I’m quite amazed that there isn’t just some software you can download as one unit that’ll allow you to do this stuff without having to know how to add in extra packages, tell various things like linkers, compliers and other robots where to find their necessary files, update with the latest versions etc! I realise that these IDEs are designed to have maximum potential for modification and stuff so that inevitably they are like this, but it makes it rather prohibitive to beginners. Well, beginners who are trying to pick it up on their own anyway!