For OS X go here.
If you have any trouble, keep reading. I may have placed a note covering your problem. If not then just post a comment here so I can help and/or update the article. Please note that the scope of this article is to get you setup with a developer environment in Windows that can also compile, for Eclipse help (C/C++) go here. That being said, I’ve included a couple of notes on using Eclipse at the bottom.
- Download the Eclipse IDE for C/C++ Developers.
- Extract it to your hard drive, I just put it on the top level (c:\) so I ended up with c:\eclipse.
- If you want, make a shortcut to eclipse.exe.
- Setup a compiler.
- Download and run this. Use ‘Current’. Install all or at least the g++ compiler. Do not install to a custom folder, use the defaults.
- Download and run this. Use the defaults and follow the script instructions. When it asks for your installation directory the slash is reverse of what it should be, this is ok. If you used the default just give it “C:\MinGW” . Note: if the script doesn’t run properly or doesn’t run at all, you can rerun it by navigating to c:\msys\1.0\postinstall and double-clicking pi.bat .
- Append the following to your ‘Path’ environment variable: ;C:\MinGW\libexec\gcc\mingw32\3.4.2;C:\MinGW\bin;C:\msys\1.0\bin
- To do this, right-click ‘Computer’ (Vista) or ‘My Computer’ (XP), click ‘Properties’, click ‘Advanced System Settings’ (Vista), then click the ‘Advanced’ tab and then the ‘Environment Variables’ button. Find the ‘Path’ variable and click edit. Be sure to add the line at the end, the whole entry is automatically selected so you could erase your entire path. That is bad.
- To do this, right-click ‘Computer’ (Vista) or ‘My Computer’ (XP), click ‘Properties’, click ‘Advanced System Settings’ (Vista), then click the ‘Advanced’ tab and then the ‘Environment Variables’ button. Find the ‘Path’ variable and click edit. Be sure to add the line at the end, the whole entry is automatically selected so you could erase your entire path. That is bad.
- Start Eclipse and try a ‘Hello World’. It should get your compiler paths automatically.
- Get and install glut.
- Copy glut32.dll to your Windows\System32\ folder.
- Copy glut.h to C:\MinGW\include\GL.
- Copy libglut32.a to C:\MinGW\lib (overwrite existing file).
- Delete C:\MinGW\lib\libglut.a.
- When starting a new Eclipse project you need to add the glut32, glu32, and opengl32 libraries. Be sure the MinGW toolset(s) are checked. If you have Cygwin it will also be visible, but do not use it unless you know what you’re doing.
- In Eclipse, go to Project -> Properties -> C/C++ Build -> Settings -> Tool Settings. Under ‘MinGW C++ Links’ or ‘MinGW C Links’ click Libraries. In the Libraries field, click the icon with the green plus sign and type in a name mentioned above. Do this for all the libraries.
Note: When using a ‘Managed Make’ project, click C/C++ Build and check the box for ‘Automatically generate make files.’ Then click Settings and the Tool Settings tab will now be visible. Libraries are placed under ‘MinGW C++ Linker’ as above.
- In Eclipse, go to Project -> Properties -> C/C++ Build -> Settings -> Tool Settings. Under ‘MinGW C++ Links’ or ‘MinGW C Links’ click Libraries. In the Libraries field, click the icon with the green plus sign and type in a name mentioned above. Do this for all the libraries.
Before compiling save your files or you will get errors. When distributing a program be sure to compile in Release mode and include glut32.dll.
Sources:
Some notes on working with Eclipse:
- When working with a Makefile project, checking ‘Generate make files automatically’ under Project -> Properties -> C/C++ Build makes things worlds easier (you can also use this option by, when creating and after naming your project, hitting ‘Next’ and ‘Advanced Settings’).
- If you’re having compile issues, double check your paths. These can be found in Project -> Properties -> C/C++ Build -> Environment. PATH is inherited from windows but you can fix minor typos here. This will avoid any relogging issues sometimes associated with such changes, although you should also fix them in your system path per the 2-2-1 instructions above.