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

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. Otherwise, here are my recommendations:

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, click this link, which is current as of May, 2011. When you click that link, look for and download the Automated MinGW installer. Run that program to install the rest of MinGW.

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.

Microsoft Visual C++ Express. This program is part of the Visual Studio series from Microsoft. Visit this web site, choose your language, and the program is downloaded. I've not played with it much, but it's been recommended as a good started compiler, especially if you are familiar with Microsoft's compilers or are considering updating to the full version of Visual Studio in the future.

Tiny C. It's fast. It's small. It's very popular. Especially if you have an older PC that's not very fast, I highly recommend the Tiny C compiler. Visit the Tiny C web site and click the link to download the Windows executable.

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.

Dev-C++. Lots of readers recommend the Dev-C++ IDE from Bloodshed. Visit their web site for more information.

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

The Geany editor is recommended by reader Paul: Geany

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 wont, 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 7, Vista, and XP and Windows 98. (I no longer support Windows ME and do not have Windows 2000/NT workstation.)


Windows 7 & Windows Vista & Windows XP

Some older versions of the MinGW compiler have trouble installing on Windows Vista. If you are experiencing problems with the MinGW installer in Windows Vista, click here.

1. Open the Control Panel's System icon; the keyboard shortcut is Win+Break (my favorite keyboard shortcut). Win+Break is also the Win+Pause key, should your keyboard not show the Break key.

2. If you're using Windows XP, skip to step 5.

3. In Windows 7 and in Windows Vista, choose Advanced System Settings on the left side of the System window.

4. In Windows Vista, click the Continue button or type in the Administrator's password to get by the UAC warning.

5. If necessary, click the Advanced tab in the System Properties dialog box.

6. Click the Environment Variables button.

7. Choose the Path variable from the bottom part of the dialog box, shown above.

8. Click the Edit button.

9. Click in the Variable value text box.

10. Press the End key on your keyboard so that you may add text to the end of path.

11. Type a semicolon, ;

12. Type the path to the BIN folder, as in:

;c:\mingw\bin

13. Double-check! There should be no spaces in there.

14. Click OK to close the Edit System Variable box.

15. Click OK to close the Environment variables box.

16. Click OK to close the System Properties window.

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

Windows 98

1. From the Start button choose the Run command.

2. In the Run dialog box, type msconfig:

3. Click OK.

4. Inside the System Configuration Utility window, click the Autoexec.bat tab.

5. Click to select the PATH line:

6. Click the Edit button.

7. 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

8. Double-check!

9. Click OK.

This change takes 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 compiler. Save this, then restart your computer.

Any questions? E-mail me:

dan at c-for-dummies . com