compiler tips

Departments

Main

About

Errata

FAQ

Compiler Tips

Supplemental Lessons

NCurses

Source Code Files

On-line Book Ordering

Compilers for Unix-based systems...

Compilers for Windows...

A great on-line C language reference


Unix/FreeBSD/Linux/Mac OS X

linux

As was stated in the book, the gcc compiler comes with your operating system and it will work in the special directories you've set up. You're all set. You are the future.

Tip: If you're using the command line, then most command shells support a history function; you can use the up arrow key on the keyboard to recall a previously-typed command. Use this to help you quickly re-edit and re-compile.


Windows

The following information supplements what is found in Appendix A in the books. Please refer there first and then here next.

Tip: With most Command Prompt windows you can use the up arrow key on the keyboard to recall a previously-typed command. Use this to help you quickly re-edit and re-compile your stuff.


Suggested Compilers

MinGW: Minimalist GNU For Windows. A port of the GNU gcc compiler that I used for writing the books.

To download a copy of MinGW, visit this site (link opens in a new window):

http://www.mingw.org/

Click the Download link on that page. Look for the Automated MinGW Installer. Below that category you'll find a link to an exe (program) file. Download that exe file.

The Automated MinGW Installer is a tiny program. By running that program, you can grab the rest of the MinGW files from the Internet and install them automatically.

Remember: MinGW is a command prompt program. It is not a complete environment. Refer here to learn how to get the gcc command to work in your folders when compiling at the command prompt in Windows.

Dev-C++/Bloodshed compiler. The compiler they use with the Dev-C++ environment is the MinGW compiler. Same thing.

DJGPP. This is a custom version of the popular GNU C/C++ compiler that should also work with the books. It's been several years since I've downloaded a copy of DJGPP, but I assume that it should work well with the book. Here is the link (opens in a new window):

http://www.delorie.com/djgpp/

Other compilers.

If you know of any other compilers that are GCC-compatible or based on GCC, please do let me know. I'd be happy to list them here. Send e-mail to

dan [at) c-for-dummies.com

IDEs

The book doesn't mention any IDEs, but if you're new it might help you to check out a few of them. Especially when you plan on creating large projects, an IDE is a boon to productivity. Remember that I cannot offer support for an IDE, but here are some I recommend or which have been recommended to me.

Code :: Blocks. Runs on Linux, Mac, and Windows. A great way to set up a compiler under Windows Vista without having to mess with the intricacies of MinGW. Link.

Text Editors

I suppose I should also mention various text editors available, especially if you're going to be using the command prompt to create your programs (as I do).

The editor I use is VIM, though it's advanced, scary, and intimidating:

VIM

Another popular editor is GNU Emacs, though it also isn't the most friendly editor in the world. For more information on the Windows version, see: http://www.gnu.org/software/emacs/windows/

Here are a few easy-to-learn and use text editors as recommended by one of my Forum contributors, Brad:

Notepad2

Notepad++

Crimson Editor

Finally, some additional recommendations, though these may not be as easy to use as the previous three:

Context

PSPad

Getting the GCC command to work in any folder

The best way to get the gcc command to work in any folder on your hard drive is to place the bin folder (where gcc lives) onto the Windows search path. This can be complex, so pay attention!

First you need to know where the bin folder is located, the bin folder's path. This is the hardest part because most folks began using computers with Windows, which doesn't emphasize paths as much as command prompt OSs do.

If you've installed MinGW according to its wonts, then the path to bin may look like this:

C:\MinGW\bin

(This can be seen in the Address Bar if you open the bin folder in a window.)

Or if you installed MinGW in the Program Files folder, the path may be:

C:\Program Files\MinGW\bin

Or maybe you're using another compiler and the path is something like:

C:\OtherGCC\bin

Or:

C:\Program Files\OtherGCC\bin

Whatever! Write down or memorize or copy that path. It's important. It must be accurate!

Second, you need to modify the path environment variable in Windows so that Windows knows where to look for GCC and its companion commands. The following sections describe how to do this for Windows Vista and Windows XP and Windows 98. (I no longer support Windows ME and do not have Windows 2000/NT workstation.)


Windows Vista & Windows XP

I've recently installed the MinGW 3.4.5 compiler on my Vista computer using their automatic installation program. Because of this, I've not had any problems with lost files in MinGW. if you are experiencing such problems in Windows Vista, click here.

Open the Control Panel's System icon; the keyboard shortcut is Win+Break (my favorite keyboard shortcut).

In Windows Vista, take the extra step of clicking on the Advanced System Settings link to see the System Properties dialog box. Click the Continue button or type in the Administrator's password to get by the UAC warning.

In the System Properties dialog box, click the Advanced tab. Then click the Environment Variables button.

Choose the Path variable from the bottom part of the dialog box, shown above. Click the Edit button.

Click in the Variable value text box and press the End key on your keyboard so that you may add text to the end of path.

Type a semicolon, ;

Then type the path to the BIN folder, as in:

;c:\mingw\bin

Double-check!

Click OK to close the Edit System Variable box. Click OK to close the Environment variables box. Click OK to close the System Properties window.

The changes take affect with the next DOS prompt window you open. If you were successful, then you can run the gcc command in any folder/directory at the DOS prompt.

Windows 98

From the Start button choose the Run command.

In the Run dialog box, type msconfig:

Click OK. This displays the System Configuration Utility. Inside that window, click the Autoexec.bat tab. Then click to select the PATH line:

Click the Edit button. At the end of the existing path, add a semicolon and then the path to MinGW or your C compiler, whatever that is. For example:

;c:\mingw\bin

Double-check! Then click OK. This change will take affect after you next restart the computer; do so now if prompted.

NOTE: If you don't see a line with PATH= on it anywhere in the scrolling window, then you'll have to create one. Click on the New button, then type:

path=c:\mingw\bin

Or specify whatever the path may be to your compilter. Save this, then restart your computer.

Any questions? E-mail me:

dan at c-for-dummies . com