Thursday, August 23, 2012

Windows 7: Eclipse CDT + OpenGL + MinGW Part 4

Setting up the FreeGLUT project


  1. In Eclipse...
  2. File > New > Project > C/C++ > C++ Project
  3. Hello World C++ Project w/ MinGW GCC
  4. If you didn't see MinGW GCC then uncheck the box "Show project types and ....".
  5. Name the project and finish.
  6. Copy the lib and include folders you've been adding things to over to the eclipse_workspace folder and place them next to the project's src folder.
  7. In Eclipse, right click on the project > Properties > C/C++ Build > Settings
  8. GCC C++ Compiler > Includes > Include paths (-I)
  9. Click the button with the green plus sign and add the "workspace" path to your folder "include" that you copied into the project folder.
  10. MinGW C++ Linker > Libraries.
  11. Go to Libraries (-l) and add: "glu32", "opengl32", "freeglut".
  12. These need to be in a proper order to try to keep them in the order I just described, from the top to the bottom (glew32 on top, then glfw, then...).
  13. Go to Library search path (-L)
  14. Add the "workspace" path to the "lib" folder you copied into the project folder.
  15. Click "Apply" and "Ok".
  16. Take the .dll's you copied into your "bin" folder and copy them into the project's "debug" or "release" folder. I use "debug", and it's what I've confirmed to work, so copy them into the "debug" folder.
  17. Copy and paste the code here over the hello world code. This will run the spinning cube dude:  http://pastebin.com/RfdPESsz
  18. Right click the project and "Build" (or hit the hammer button up top).
  19. Right click the project and "Run As" > "Local C/C++ Application".
Setting up the GLFW project


  1. In Eclipse...
  2. File > New > Project > C/C++ > C++ Project
  3. Hello World C++ Project w/ MinGW GCC
  4. If you didn't see MinGW GCC then uncheck the box "Show project types and ....".
  5. Name the project and finish.
  6. Copy the lib and include folders you've been adding things to over to the eclipse_workspace folder and place them next to the project's src folder.
  7. In Eclipse, right click on the project > Properties > C/C++ Build > Settings
  8. GCC C++ Compiler > Includes > Include paths (-I)
  9. Click the button with the green plus sign and add the "workspace" path to your folder "include" that you copied into the project folder.
  10. MinGW C++ Linker > Libraries.
  11. Go to Libraries (-l) and add: "glew32", "glfw", "glu32", "opengl32".
  12. These need to be in a proper order to try to keep them in the order I just described, from the top to the bottom (glew32 on top, then glfw, then...).
  13. Go to Library search path (-L)
  14. Add the "workspace" path to the "lib" folder you copied into the project folder.
  15. Click "Apply" and "Ok".
  16. Take the .dll's you copied into your "bin" folder and copy them into the project's "debug" or "release" folder. I use "debug", and it's what I've confirmed to work, so copy them into the "debug" folder.
  17. Copy and paste the code here over the hello world code. This will run the spinning cube dude:   http://pastebin.com/yXDzXPYq
  18. Right click the project and "Build" (or hit the hammer button up top).
  19. Right click the project and "Run As" > "Local C/C++ Application".
The GLFW project will build fine but for me I have to run it from the project's debug folder. You can of course run it in debug in the editor just fine.

Here is a copy of my project folders. Everything is referenced from within the project workspaces so things should be portable: THE_PROJECTS.

Wednesday, August 22, 2012

Windows 7: Eclipse CDT + OpenGL + MinGW Part 3

First, pick a place that you won't delete and create the following folders:

  • include
  • lib
  • bin
Now, what are these things going to be for?

FreeGLUT is an up-to-date version of the popular GLUT kit. It makes OpenGL easier to work with by providing windows and some other functionality for you (making the windows is a platform specific thing that is just plain lame and a fucking drag to do in order to get a spinning fucking cube. Fuck.). It's cross platform but doesn't work well on OSX I believe.

GLFW is an alternative to FreeGLUT. It provides windowing and input and some other stuff. Works well on Windows/Linux/OSX. My favorite (o^_^)b.

GLEW allows you to easily enable any extensions you may need. The alternative is sheer torture (maybe not at first but eventually). GLEW it.


FreeGLUT

  1. Go to :  http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/.
  2. Click: "freeglut MinGW Package".
  3. Alternatively, you can follow this link: http://files.transmissionzero.co.uk/software/development/GLUT/freeglut-MinGW.zip
  4. Get the zip file and expand it.
  5. Copy the freeGLUT bin .dll's to your bin folder you made.
  6. Copy the freeGLUT include contents ( copy the entire GL folder ) and put it into the include folder you made.
  7. Copy the freeGLUT lib contents into the lib folder you made.
GLFW
  1. Go to  http://www.glfw.org/download.html.
  2. Download the latest zipped version.
  3. Unzip the package.
  4. Open up the console (WindowsKey + R).
  5. In the windows explorer go to the folder and copy the path from the top of the window.
  6. Go back to the console.
  7. Type "cd ". Space after the cd.
  8. Paste the path you copied and press enter to travel to the folder in the console.
  9. In the console, go to the unzipped folder where the Makefile is.
  10. Run the command "make win32-msys".
  11. If the command errors out then check the "readme.html" for instructions on what other commands to use. I'm pretty sure the error will tell you the options for running the make.
  12. After a few seconds, the console should spew info about the build.
  13. Copy the include/bin/lib stuff like you did before.
  14. Note that you should add the new include/GL stuff to the folder you've already made.
GLEW
  1. Go to  http://glew.sourceforge.net/ and download the latest ZIP.
  2. Don't get the binaries, you will be building it yourself yo.
  3. Unzip the package, console to it, make.
  4. Copy the bin/lib/include stuff like before.

Windows 7: Eclipse CDT + OpenGL + MinGW Part 2

Eclipse CDT C++ plugin( 4.2.0 = Juno )
  1. Open Eclipse.
  2. Go to Help > Install new software > Work with.
  3. Paste in: http://download.eclipse.org/tools/cdt/releases/juno
  4. Press Enter.
  5. Expand "CDT Main Features".
  6. Turn on "C/C++ Development Tools"
  7. Expand "CDT Optional Features"
  8. Turn on: " C/C++ GCC Cross Compiler Support", "C/C++ GDB Hardware Debugging", "C/C++ Memory View Enhancements", "C/C++ Unit Testing Support", "C99 LR Parser", "CDT Visual C++ Support".
  9. Press Next, Finish, w/e. Just go through the installation steps, accept things, until it tells you that it needs to restart.
  10. Allow Eclipse to restart.
MinGW
  1. Go to: http://sourceforge.net/downloads/mingw/MinGW/
  2. Click on (The link will look something like this)"Download mingw-get-inst-20120426.exe (662.7 kB)"
  3. Run the installer.
  4. Say that you want the latest version from teh webz.
  5. Let it do it's thing. Go grab a drink or something.
  6. Go to wherever you installed it and make note of the path to the mingw bin (by default this is C:\MinGW\bin).
  7. Also make note of the mingw msys bin (by default this is C:\MinGW\msys\1.0\bin).
  8. Copy these 2 paths onto the end of your system PATH.
  9. To append these to the path, go to windows start and enter the string "advanced".
  10. Click "View advanced system settings".
  11. Click "Environment Variables".
  12. Go to the "System variables" region at the bottom.
  13. Scroll down to "PATH" and click edit.
  14. Go to the end of this possibly long bigass string and enter a semicolon ";" to separate the last entry from the ones you want to add.
  15. Add the two paths to mingw bin and msys bin (separate these by ";").
  16. Test if you have mingw working now by opening up the console and running make.
  17. Press WindowsKey + R. This will open up RUN.
  18. Type cmd.
  19. Press enter.
  20. Run the command: "make --version".
  21. Run the command: "g++ --version".
  22. If these commands don't error out and complain about something then you are good to go with mingw!

Windows 7: Eclipse CDT + OpenGL + MinGW Part 1

So, I get tired of Visual Studio.

I get tired of it in general, I get tired of it's look, I get tired of it bugging out... And with all the Windows 8 stuff I've been reading about with the "you will develop for Metro or gtfo" what not, I just feel like now is a good time to take my OpenGL preferring self and get away from Visual Studio.

I really like Eclipse. It's easy to work with, it's free, it's got ton's of plug-ins, and it's easy to change the look with templates that don't break everything. Also the code completion is great. In Visual Studio I use Wild Tomato's Visual Assistant X. In Eclipse, I get a free and awesome code completion solution. Score.

Anyway, setting up Eclipse to develop C++ meant installing the CDT plugin. Painless.
Getting OpenGL's spinning cube hello world working... Painful.

But, it always is painful to get OpenGL started up on some dev environment you aren't experienced at working with yet.

So, let me distill the knowledge I have acquired by mentally cartwheeling nude through numerous forums and guides to you, the consumer, so that you may immediately get an OpenGL Spinning Cube application up and working using not only FreeGLUT, but also GLFW and GLEW.

Tuesday, August 21, 2012

Windows: CMake can't find QT? Whaaaattttt....

I got this error while checking out a project.

I found the solution on StackOverflow (http://stackoverflow.com/questions/9933939/cmake-not-finding-qt4).

Plain and simple: add the path "C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin" to your advanced system settings PATH variable.

If you're using Qt 4.8.1 or w/e else change it accordingly. Just make sure you get the msvc2010\bin path.