Hours…. literally a handful of hours trying to setup MinGW for my class projects. Yeah, MinGW was kicking my butt… I just threw my hands up, waved the white flag, and gave up. You may have saw in the last post that we did get Freeglut working… but once it came to glew32, it all came unglued.
So yeah, here we go again. Nice and fresh. I download the source for glew and source for freeglut. I used Cmake and Visual Studio 2015 to compile the libraries (dynamic and static/debug and release). I’ll include them here for convenience’s sake.
- These are not needed for tutorial below
Let’s make a simple file main.cpp file to make sure we are up and running.
First thing to understand is static vs dynamic libraries. Simply put, static libraries are compiled into the exe whereas dynamic libraries exist outside the exe as dll files. In this post, I’ll deal exclusively with dynamic libraries.
Download and extract my Visual Studio 2015 Dynamic Freeglut and Glew32 zip file into your Project directory (with main.cpp). Now we have to setup the dependencies and other settings on the project itself. So go to the Project’s Properties (Right click Project and click Properties).
First, we want to make sure we are including headers in our include folder. Select ALL CONFIGURATIONS. Under C/C++ > General > Additional Include Directories, add include.
The code that we will be dealing with, we need to set a preprocessor flag, so here we add at the beginning _CRT_SECURE_NO_WARNINGS;
Let’s include our freeglut and glew32 libraries. We add both the release and debug version of the library in all configuration for ease.
Finally, we do a little Post-Build scripting to copy over the DLLs and Shaders from our project directory to our output directory. xcopy /d /y silently copies over the file only if newer. Notice we have a different copy statement between Debug and Release since we want to copy over the different DLLs.
OK. We’re done! Here’s an example using these libraries and settings. Check out this visual studio solution (Project1.zip)!
PS – I used a slightly different folder structure than the tutorial, but everything else is the same.