Compiling libraries is something that a lot of indie game developers have trouble with, especially if they are using Eclipse or CodeBlocks with MinGW. Compiling libraries is just one of those things that people just assume you know how to do, although it doesn't seem like there is all that much information, (or information that is clear) on how to properly build libraries. They never even taught me how to do it in college .
I am specifically going to teach you how to compile libraries for your indie game using MSYS and MinGW. I am going to use glew32 as an example, since that is a very popular library, especially for those working with OpenGL.
I will explain step by step how to compile the libraries.
Step 1: Download MinGW and MSYS. They should be on the main website, and shouldn't be too hard to find. MSYS will usually be downloaded along with MinGW.
Step 2: Make sure you downloaded MinGW to your C:\ directory, and that msys is inside of the folder.
Step 3: Add the folders C:\MinGW\bin and C:\MinGW\mingw32\bin to your PATH: variables. VERY IMPORTANT, I'm guessing a lot of people skip this step by accident. You can find the path variables by going into search, and typing "path variables". You need these in your path variables so that way cmd.exe has global access to the programs inside of these folders, without having to change directories.
Step 4: Download the Glew32... tsk... "libraries", off of the glew website.
Step 5: Open cmd.exe
Step 6: type: cd, and a space after it and then copy/paste the file directory to the Glew folder that has a MakeFile in it. into the cmd.exe window.
Step 7: press enter, and then type bash, and then press enter again. now you should see a dollar sign appear in the cmd window. If you do not see a dollar sign, then chances are that you didn't properly add MinGW\bin or MSYS\bin to your PATH variable.
Step 8: type mingw32-make, and then press enter. Now it should lag a little, but if you wait a while, you should see a lot of weird, err, stuff appear in the window. That's ok, that's normal. That means you did it right!. Now if you wait a while, you should see bash appear at the bottom with the dollar sign again, and it should look something like this.
Step 9: you have just compiled your libraries! Great! ...where are they? Well if you look inside of the lib folder of your glew32 folder, you should see a bunch of new stuff there that wasn't there before. You should see a libglew32.a and a glew32.dll. Now Those are the important ones! The .a one is the static library, and the .dll is the dynamic one.
Step 10: If you wish to use these libraries, i suggest putting them into different folders so that your ide has an easier time finding them. For example, Eclipse will sometimes confuse libglew32.a with libglew32.dll.a.
And that's it!
Now, there are a few gotcha's:
Make sure everything you are downloading is of the same bit amount, for example, make sure everything is 32-bit. And I mean, EVERYTHING! Including your program, and your other libraries.
Not all libraries you download off of the internet will have a makefile, and not all makefiles require the same procedures as simply typing mingw32-make. For example, the Freetype library, also a very popular library for game development, requires that you type ./configure first, before typing mingw32-make. It is VERY important to read the read me file of any library you download, as they may provide valuable information.
As for the libraries that do not have makefiles, for example, the boost libraries, which have .jam files instead. You will need a different compiler program sadly. There are many different compiler programs that are beyond the scope of this tutorial i'm afraid, however I am sure there are video tutorials that can teach you how to use them.
And that's it, that's how you compile libraries with MinGW and MSYS for C++. Thank you for reading my tutorial ^^.