Dev-C++ for Windows

Dev-C++ is an open source application available from Bloodshed Software (www.bloodshed.net, Figure A.1). Not only is Dev-C++ free, but it runs nicely on any version of Windows since Windows 95, and requires just a mere 32 MB of RAM.

Figure A.1. The home page of Bloodshed Software.


Dev-C++ is a syntax-highlighting text editor and it includes the required C compiler, letting you run the compiled applications directly from within Dev-C++. In short, if you're developing C applications on Windows, you can't go wrong with Dev-C++ (although it has C++ in the name, it's also great for C). All of the examples in this book were written on and tested using Dev-C++ (on Windows 2000).

The following sequences constitute a mini “quickstart” guide to using Dev-C++. Also be sure to check out the debugging section, later in this appendix, since the full version of Dev-C++ comes with the popular Gnu Debugger (GDB) installed.

Customizing Dev-C++

Installing Dev-C++ is easy enough—just run the downloaded installer—but make sure that you download the full version, which includes the compiler. Once you have Dev-C++ on your computer, you'll want to set the preferences before using it too much. Specifically, we recommend the following instructions.

To customize Dev-C++

1.
Create a directory for your C files. The best option is to create a simply titled directory in the root of the hard drive, like C:c_code.

2.
Open Dev-C++.

3.
Select Options > Compiler Options.

This will bring up the Compiler Options dialog.

4.
Click the Add the directory below to be searched for include files check box.

In the long run, it will improve how easily you can develop applications if you use a set directory for storing all of your C code.

5.
Type your C code directory in the box below that (Figure A.2).

Figure A.2. Set your preferred directory (or directories) in the Compiler Options dialog.


You cannot use directory names here with spaces in them, but you can add multiple directories by separating each with a semicolon.

6.
Click on the Linker tab and click the Generate debugging information check box (Figure A.3).

Figure A.3. In order to use the built-in debugger, you must have Dev-C++ generate debugging information.


By doing this, you can use the debugging tools built into Dev-C++.

7.
Click the OK button to exit.

✓ Tips

  • Through the Dev-C++ Resource Site (http://bloodshed.net/dev/), you can download other packages, like GUI toolkits for creating graphical interfaces for your applications.

  • Once you've gotten through the first chapter, you may want to check out the Misc tab within the Environment Options panel (accessible by selecting Options > Environment options). There you can set the default code for creating a new source file.

  • At the time of this writing, we were using version 4.x of Dev-C++. Version 5 should be available by the time you read this book (it was in beta at press time) and would be preferable, as it uses a newer compiler, among other benefits.


Using Dev-C++

Although using Dev-C++ is pretty straightforward, understanding how to use it with respect to the code and steps in this book merits discussion. The instructions for creating the examples are somewhat generic—so that users on any computer using any text editor or IDE can follow along—but here is how we envision Dev-C++ people going through the material.

To use Dev-C++

1.
Open Dev-C++.

2.
Select File > New Project to create a whole new project.

We like the idea of working with projects even though most of the applications in this book use only a single file at a time. Getting into the habit of creating projects will help you down the line when you're developing larger-scale C tools.

Alternatively, you can select File > New Source file to begin creating a single C source document.

3.
In the New Project window (Figure A.4), do the following:

  • Click on the Console Application icon.

  • Ensure that C project is selected.

  • Ensure that Make default language is selected.

Figure A.4. The New Project window in Dev-C++.


Certainly Dev-C++ has more to offer—as you can tell from the New Project window—than a plain console application, but for the purposes of this book, that's where you'll want to start out.

4.
Click OK.

5.
Enter the project's name (Figure A.5) and click OK.

Figure A.5. Naming the new project.


For your project name, use the basename of whatever file is being created. So if the example is making a file called hello.c, name your project hello. Each example has its name near the very top of the step-by-step sequence, so you shouldn't have to go hunting around for that information.

6.
Select the project's location (Figure A.6).

Figure A.6. Use the standard Windows interface to navigate to and select the desired location for your new project.


You should use the same directory as you created in the Customizing Dev-C++ sequence. We also recommend using a separate directory for each project, to help maintain the organization of your work.

7.
Click Save.

After going through these steps, you'll be given a C source template (Figure A.7).

Figure A.7. The default C template.


8.
Enter your C code.

You can now follow the particular instructions for an example, typing all of your code in the template so that it matches that in the book.

9.
Select File > Save Unit.

This will let you save the C source file itself. You can name it either hello.c (a name matching the project name) or main.c.

10.
Select Execute > Compile or press Ctrl+F9.

The compiler is linked to the Dev-C++ application, so you can compile your C code within it.

11.
If the application compiled successfully, select Execute > Run or press F9.

This will create a new console window (a DOS prompt) and begin running the compiled application.

12.
If the application did not compile successfully, check the compiler tab (at the bottom of the screen) for error messages.

Any syntax errors in your code will be listed in the Compiler tab. The specific line number where the problem occurred is listed as well.

✓ Tips

  • Steps 10 and 11 can be combined by selecting Execute > Compile and Run. Of course, you can always use the toolbar icons as well.

  • On the Dev-C++ Resource Site (http://bloodshed.net/dev/), check out the Documentation page, which has links to various manuals, Web sites related to C and C++, and tutorials on using Dev-C++.

  • You can create other templates that will appear in the New Project window by placing them in the Dev-C++Templates directory.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset