Some of the instructions in this file are subject to change especial if there is an upgrade to one of the programs.
Bushido Hacks and BushidoHacks.com are not responsible for any problems that are the result of the installation, usage, or abuse of the programs mentioned in this file that may occur to your computer or any other device. As the reader of this page, agree that you are responsible for whatever problems that occur even it it was the result of reading the instructions throughly, not read them throughly, or reading this disclaimer or the general disclaimer. If you install these programs, you consent to installing them on your own volition. This means you can not blame Bushido Hacks or BushidoHacks.com for anything bad that happens to your computer as a result of following the instructions or using the programs in this file.
In short, READ EVERYTHING FIRST! When in doubt, don't try it out.
The GNU compiler collection is a free C and C++ compiler created by the Free Software Foundation that complies with ISO standards. FSF offers the GCC source codes online as part of the GNU project. FSF does not distribute binaries. Binaries are the executable programs created from the source code.
GCC comes standard with nearly every UNIX, BSD, and Linux distribution and possibly MacOS X, but not Windows. Even compiling the compiler from source code is troublesome to most Windows users. On top of that, there are a few other utilites that you need to download to take advantange of the same features on Windows that UNIX and Linux users have.
Fortunately, a few people took it upon themselves to spend the time and energy to create a Windows port of GCC and the basic binary distributions. This port is part of an online project called MinGW. MinGW is a collection of freely available and freely distributable set of Windows specific header files and import libraries combined with GNU toolsets that allow a programmer to produce native Windows programs that do not rely on any thrid-party C runtime DLL files. This freedom allows MinGW to be able to be stored onto a thumbdrive or other removable media.
However, just like GCC, MinGW is not one piece and adds a large about of internationalization that occupies a significant amout of storage. Internationalization is the translated source codes for other languages and dialects. Say for example, your native language is Chinese instead of English. While you may still want the Chinese langage support, the Spanish, French, German, Dutch, Italian, Norwegian, Sweedish, Russian, Thai, Arabic, Japanese, and several other languages that you don't speak are adding hundreds of files that you will never use. That means, many of the files that you created when you installed the program now have to be destroyed in order to reclaim space.
A good recommendation for native language support is to delete all the internationalization files except for English and your native language.
Another problem with installing MinGW directly is that you have to download several files. Just as you would rather skip to the installation instructions than read this dialog (gotcha!), you want to cut to the chase and get to work right now. (By the way, it's OK if you don't want to read this part. You can move down to the next section if you'd like.) This process takes some time for some people, time that could be used productively writing programs.
At the time this document was written, I was in a rush.
Enter Bloodshed Software's, Dev-C++. Dev-C++ is just an IDE, or Integrated Development Environment, for C, C++, and OpenGL. Personally, I don't use the IDE. Dev-C++ is quite clumsy when it comes to using tabs and whitespace, which is noticable when opening a C++ file that was created in Dev-C++ in another program such as Vim. Because the Dev-C++ IDE handles aligning codes neatly like an inebriated person walking a straight line, I like to use Vim instead of the Dev-C++ IDE. That and Vim won't crash if something bad happens.
So why install something that has trouble working in the first place? It's not so much that we need the Dev-C++ IDE, we just want to use the GNU utilies and GCC Windows binaries that come with it.
OpenGL is a standard specification defining a cross-language cross-platform application programming interface for composing applications that produce computer graphics. (Yea, alot of of big words.) Cross-language means that OpenGL is available in more than one programming lanugage such as Java and C++ but the codes are similar enough that they are compatible with other languages. Cross-platform means that OpenGL is available for more than one operating system such as Windows or Linux and can be ported to each other with a low amount of modification. An application programming interface, or API, means that OpenGL is an interface that a library (OpenGL is short for "Open Graphics Library") provides in order to allow request for services to be made of it by other computer programs to allow data to be exchanged between them. Basically, there is alot of assembly programming involved. It's something to talk about for some other time.
Unlike Java (which uses non-OpenGL graphics), C++ does not include graphics. It was this misleading belief that convinced me to not use Borland Turbo C++, which uses graphics that Borland created, and are NOT part of the C++ standard or the OpenGL API. However, many computer science instructors use Borland's graphics abilities to teach the basics of C++ and to introduce students to computer graphics.
Imagine that the C++ standard is like a bowl of cerial. Using Borland and Visual C++ are like cerial with the marshmallows in it. While the marshmallows (the added graphics from Borland and Microsoft) may make the cerials taste more appealing and more interesting, the sugared down cerial with its artificially sweetened taste eventually rots your teeth.
OpenGL is like adding your own bananas to make the bland but cruchy cerial taste better and naturally sweat. Rather than being filled up with the sugar that comes in the box of cerial, the nutrients of the banana make the cerial taste better and better for you.
The point of this analogy is that it is better to know how something works by creating your own graphics, than to be given a set of functions you don't know anything about and be told to use them because that's how they work.
The best OpenGL API allows users to create their own graphics without being tied down by a bunch of graphics drivers and .dll files that compilers like Borland and VC++ ask you to put in your system folder. The last thing any system administrator wants people to do is add or remove stuff on to their computers without their consent. (Even if you did ask, the answer would generally be "No.") This is why there are added instructions for installing software to a removable media device such as a thumbdrive in this document. You are still able to create graphics but you don't mess with their system.
In recent years, the GCC compiler has come with OpenGL headers and libraries. The headers GL/gl.h and GL/glu.h are included. Continuing the banana analogy, think of the GL directory as the banana tree. GL/gl.h and GL/glu.h are like the bananas that are still on the tree. If you don't know how to get the bananas down from the tree, you go hungry. While some people chose to climb up the tree to get the bananas, some people have create tools to bring down the bananas. One tool that was developed is called GLUT.
GLUT (rhymes with "butt") is the OpenGL Utility Toolkit. It includes added utilities that allow you create graphics without loading you with sugar as a solution. Think if GLUT as a pointed stick that knocks down a few bananas from the tree as opposed to climbing up the tree to get the bannas. Climbing the tree is the hard way. Giving up and eating cerial with sugar is the easy but wrong way. The stick, on the other hand, is not the easy way to get the bananas, it is the SMART way.
GLUT has recently been included in some UNIX and Linux distributions. Their graphics are a product of a graphics library called FreeGLUT, an open source version of the GLUT library based on another open source graphics library that uses OpenGL called Mesa. Mesa was originally an open source alternative to OpenGL until Silicon Graphics, Inc. (SGI), the creators of OpenGL, made the source codes for OpenGL publicly available. Mesa's development made it possible for GLUT to still do things that SGI had not though of. However, FreeGLUT is not for Windows, but GLUT is.
Fortuantely, a guy named Nigel Stewart has come up with a solution. While there are many Windows distros of GLUT available, Stewart's GLUT 3.7.6+ is the best. His is the only version that does not require a .dll file to be added to the system folder. (Generally, if you are told to put something in your computer that you don't know about, it is probably a good idea not to use it.) The only problem: the files are bundled in a .DevPak file, which Dev-C++'s Packman program recognizes. Hence, another reason why Dev-C++ was installed instead of MinGW.
| [x] | Dev-C++ program files (required) | [Required] |
| [x] | Example files | [Optional but recommended] |
| [x] | Help files | [Optional but recommended] |
| [x] | Icon files | [Optional but recommended] |
| [x] | Mingw compiler system (binaries, headers, libraries) | [Required] |
| [ ] | Language files | [Optional/not recommneded for thumbdrive/recommended for non-English native language support] |
| [ ] | Associate C and C++ files to Dev-C++ | [Optional/not recommneded for thumbdrive] |
| [ ] | Create shortcuts in Start Menu | [Optional/not recommneded for thumbdrive] |
| [ ] | Create Quicklaunch shortcut | [Optional/not recommneded for thumbdrive] |
| [ ] | Debug files | [Optional/not recommneded for thumbdrive] |
| [ ] | Remove all previous configuration files | [Optional] |
That is all for the installation. You now have the tools to create C++ programs with computer graphics.
GCC is a set of programs. But the program used to compile C codes is NOT the same as the program used to compiles C++ codes. Though this document you are reading is aimed primarily for C++ programmers, the following table shows how to compile and link and a few other important instructions for C, C++, and OpenGL programmers.
| Command | Windows | UNIX, Linux, etc. |
|---|---|---|
| Compiling and Linking C | C:\Dev-Cpp\bin\gcc.exe file.c -o program.exe | gcc file.c -o program |
| Compiling and Linking C++ | C:\Dev-Cpp\bin\g++.exe file.cpp -o program.exe | g++ file.cpp -o program |
| Compiling C to a Module | C:\Dev-Cpp\bin\gcc.exe -c file.c -o file.o | gcc -c file.c -o file.o |
| Compiling C++ to a Module | C:\Dev-Cpp\bin\g++.exe -c file.cpp -o file.o | g++ -c file.cpp -o file.o |
| Add or Update files in a new or existing archive | C:\Dev-Cpp\bin\ar.exe cruv archive.a files.o ... | ar cruv archive.a files.o ... |
| Link C Modules into a program | C:\Dev-Cpp\bin\gcc.exe -Wl--start-group files.o ... -Wl--end-group program.exe | gcc -Wl--start-group files.o ... -Wl--end-group -o program |
| Link C++ Modules into a program | C:\Dev-Cpp\bin\g++.exe -Wl--start-group files.o ... -Wl--end-group program.exe | g++ -Wl--start-group files.o ... -Wl--end-group -o program |
| Link C Modules into a program using archives | C:\Dev-Cpp\bin\gcc.exe -Wl--start-group files.o ... archives.a ... -Wl--end-group program.exe | gcc -Wl--start-group files.o ... archives.a ... -Wl--end-group -o program |
| Link C++ Modules into a program using archives | C:\Dev-Cpp\bin\g++.exe -Wl--start-group files.o ... archives.a ... -Wl--end-group program.exe | g++ -Wl--start-group files.o ... archives.a ... -Wl--end-group -o program |
| Link C Modules into a program for OpenGL | C:\Dev-Cpp\bin\gcc.exe -Wl--start-group files.o ... -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -Wl--end-group program.exe | gcc -Wl--start-group files.o ... -lglut -Wl--end-group -o program |
| Link C++ Modules into a program for OpenGL | C:\Dev-Cpp\bin\g++.exe -Wl--start-group files.o ... -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -Wl--end-group program.exe | g++ -Wl--start-group files.o ... -lglut -Wl--end-group -o program |
| Link C Modules into a program using archives for OpenGL | C:\Dev-Cpp\bin\gcc.exe -Wl--start-group files.o ... archives.a ... -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -Wl--end-group program.exe | gcc -Wl--start-group files.o ... archives.a ... -lglut -Wl--end-group -o program |
| Link C++ Modules into a program using archives for OpenGL | C:\Dev-Cpp\bin\g++.exe -Wl--start-group files.o ... archives.a ... -lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32 -Wl--end-group program.exe | g++ -Wl--start-group files.o ... archives.a ... -lglut -Wl--end-group -o program |
Here's something that is important if you have many files: creating a library or archive. Archives (.a files) are collections of modules (.o files). They are sometimes called libraries especially since some archives end with .lib.
Archives are important if you use many modules. To create an archive, use F:\Dev-Cpp\bin\ar.exe. ar.exe is the Windows port of the UNIX and Linux program ar (pronounced "ARRRRR!" like a pirate). ar is the predcessor to the tar program, used on UNIX and Linux that creates archives, which are then compressed with compression programs such as gzip or bzip. Unlike ar, tar cannot be used to bundle modules.
You should create an archive if there is a list of modules that you are happy with. A copy of the modules are put into the archive. Archives are used during linking. If you compare the linking procedure using libraries inseated of a long list of modules, you will see that using a library is much more efficent.
| Q. | Why are the executable files so big? |
| A. | That's a question many GCC users and programmers have yet to figure out. What the GCC programmers do know is that it has something to do with the Windows Operating System. |
| Q. | Why don't you use Borland or Microsoft? |
| A. | For various reasons.
|
| Q. | Why didn't you create shell scripts for UNIX or Linux users? |
| A. | If you noticed the table listing the differences between Windows and Linux commands, the Windows Commands are longer than the Linux commands. |
| Q. | Why the batch files only handle one file at a time? |
| A. | In the past, I created batch files that handled more than one file at a time. The programming got messy and time consuming. It is more organized to handle two files than it is a dozen. There is a joke that computer scientists use often to describe handling large tasks. "How do you eat an elephant? One bite at a time." It holds true considering the best way to handle a large project is to break it down into parts. |