Introduction to the Code Crusader/Code Medic IDE

Code Crusader, together with the debugging tool Code Medic, comprise an elegant, easy-to-use Integrated Development Environment (IDE) for Unix/Linux platforms. It is a free, public-domain package downloadable from the Web.

Here is an overview of the contents of this introduction:

How to obtain the packages:

Obtain both packages---you will need both Code Crusader and Code Medic---from the Code Crusader home page. That site contains both the source code, and also binaries for Linux, SGI and Solaris platforms.

Simple example:

As a simple introductory example, we will suppose our source code consists of the files x.c, y.c and i.h, all in the same directory.

Creating a project file:

You will create a project file, whose name will have the suffix .jcc, to coordinate all your activities for this project.

To create the file, type


and a window will pop up. (This actually may be a Project window from a previous project you've worked on, but this won't matter.)

To create the project file, click on File (not Files), then New Project; choose a name for the project file, and save the file. In our example here, let's call the file intro.jcc. A Project window will pop up for this project, and this is the one we will be using. (You can delete the original jcc window.)

You need to indicate which source files will be involved in this project. To do so, go to the Project window, and click on Source, then Add Files. To add one file, click on its name and then on Open. You can do this in one single operation for several contiguous files by clicking and then dragging.

Use of the project file in future sessions:

After you finish your first session with a newly created project file, in our example intro.jcc, in future sessions you invoke the file as follows:

jcc intro.jcc

Generating a makefile:

Code Crusader will actually generate a makefile for you! To get this, go to the Project window and click Project, then Update Makefile. A Compiler window will pop up, and will tell you that makemake (the automatic makefile generator) has finished successfully. (In a complex situation, you make prefer to write your own makefile, which jcc will not overwrite.)

In more complicated cases, you may of course need to customize the Makefile generated by Code Crusader. Don't edit that file directly, since it will be overwritten. Instead, click on Config in the Project window, and then edit Make.header there. When you are done, click on File and then Save in that window, and remove the window.

Editing your source files:

You may either use Code Crusader's built-in editor, or an external editor of your own choice, such as emacs or the modern vi clones elvis and vim. If you wish to use an external editor, say emacs, see the material below.

Here are some tips on using Code Crusader's built-in editor:

To edit one of your source files, in the Project window double-click on the file name (or click on File then Open, and choose the file. An Edit window for that file will then pop up, using either Code Crusader's own built-in editor or the external editor of your choice.

The default Meta key is Alt. You can use this for many keyboard shortcuts. They are listed in the pulldown menus.

There are Undo and Redo icons (counterclockwise and clockwise arrows).

To do a find or find/replace, type Meta-f (or click on Search then on Find), and fill in the popup window for the search string and (if also replacing) the replacement string. If you are doing Replace and Find, you must do a Find first (but this is not necessary for the Replace All operation).

To check matching of parentheses, braces, etc., it is fastest to use Meta-b. (Otherwise, click on Search, then on Balance Closest Grouping Symbols.) The space between the parenthesis and its mate will be highlighted on the screen.

Using an external editor:

Go to the Project window and click on Preferences, then Choose External Editor. A window will pop up; click on the square labeled "Use external editor," so that it changes from gray to white. Then change the two shell commands, e.g. in the emacs case to

emacsclient $f


emacsclient +$l $f

Also, in your emacs startup file, ~/.emacs, place the line


(The program emacsclient enables communication between emacs and another process, in this case jcc.)

Compiling your program:

Go to the Project window and click Make. The result will appear in the Compiling window.

If you have an error, then do control-double-click (don't forget the control key) on the file name within the error message. The cursor in your Edit window will move to the line containing the error. (If you did not yet have an Edit window for this file, one will be created.) After you fix the error, you can then click on Make again. You do not need to save the modified source file; this will be done automatically for you. (Except, I found, if you use an external editor other than emacs, in which case you must both save your file and exit from the editor.)

Running your program:

In the Project window click on Run. A Run window will pop up, serving as a terminal for any activity in stdin and stdout your program has.

If your program has command-line arguments, in your Project window, click on Project, then on Run Settings, and put them next to a.out or whatever your binary's name is within that window.

Debugging your program:

Code Medic may be invoked from one of the Code Crusader windows, but I found that this did not work properly, because it did not load the symbol table.

Instead, invoke Code Medic from your shell command line. If your executable file is named a.out, type

medic a.out

Code Medic is an interface to gdb The Run, Next, Step and so on (except that "next" and "step" seem to have meanings reverse of those in gdb, and unlike the case of gdb, hitting Run will not automatically pick up your command-line arguments from the last run). Two windows will be set up, one showing the source file and the other being a gdb window. (You will typically use the latter only for stdin/stdout activity of the program, and special gdb commands not covered in the source file window.)

To set a breakpoint, go to the line number in the Source file window (not your Editor window), and click there. A red dot will appear. (If it doesn't, you have not loaded the symbol table.)

To have a variable continuously displayed, so you can watch it change as you step through the program, highlight the variable anywhere it appears in the source window (click and drag the mouse pointer), and then click on Debug, then on Display Variable. A Variables window will pop up.