Skip to the content of the web site.

Command-line compilation

IEEE Spectrum Magazine    MIT Technology Review    Wired Magazine    EDN Network    EE Times    Skeptic's Guide to the Universe

An integrated development environment (IDE) combines an editor, the compiler and a debugger, together with additional tools. Each of these, however, can be implemented as a stand-alone executable.

Directory structures

To use a command-line interface, you must first understand the directory structure used for organizing files on a storage medium. In all cases, there is a root directory, represented as C:\ in Windows (Windows allows for a computer to have different drives, each identified by a letter. The main drive is usually C:, as the oldest computers had two floppy drives A:\ and B:\ and when the first hard drives were introduced, it was given the identifier C:\) and / in Unix (including various flavors of Unix, Linux and Mac). Each directory can store files and other directories. A directory within a given directory is called a sub-directory of the given directory. For example, once I have installed Cygwin on my Windows 10 computer, the root directory contains seven sub-directories:

     cygwin64            PerfLogs            Program Files       Program Files (x86)
     Temp                Users               Windows

Thus, one would say that Program Files is a sub-directory of the root directory.

On the Linux computer I am currently using, the root directory contains more sub-directories

     boot        dev         etc         home        home-fast   libexec     media
     mnt         opt         opt-src     proc        root        run         srv
     sys         test1       testing     tmp         usr         var         web

and some files:

     centos7-eceLinux.sh             centos7-eceLinux.zip

Thus, one would say that centos7-eceLinux.zip is a file with the root directory and tmp is a sub-directory of the root directory.

Note: If you ever use temp to identify a temporary file or directory, you are clearly marking yourself as a Windows user. Linux and MacOS users would use tmp.

Each directory has its own purposes, and one of these directories is for the personal files of individual users. In Windows, it is the directory C:\Users while in Unix it is /home (the directory /usr is used for, among other things, non-operating-system files and applications).

Inside these directories, each user has its own sub-directory:

Home computerC:\Users\Douglas
Work computerC:\Users\dwharder
Work computer (Cygwin home directory)C:\cygwin64\home\dwharder
eceubuntu/home/dwharder

When you install Cygwin on your computer, it creates a home directory for you within the C:\cygwin64\home directory.

You will notice how each directory is given an absolute address by starting with the root directory (either C:\ or /) followed by the sub-directory, followed by the sub-directory within the sub-directory (and so on), with the directories separated with either a \ or a /. This is known as the absolute path to the directory.

On your own computer, you can place files and new directories almost everywhere, but if you are logged onto a university computer, you can only make changes to your home directory.

If you were to log onto eceubuntu (using your uWaterloo User ID and the same password you log onto Quest), you will see only one sub-directory: /home/dwharder/public_html. If you place any files into this directory, they will appear at the web site ece.uwaterloo.ca/~uwuserid/ where uwuserid is your uWaterloo User ID).

When you install Eclipse, you are asked to place the Eclipse directory wherever you wish, but usually you will place it in your home directory. Additionally, when you first launch Eclipse, it will ask you for the name of a workspace. Thus, currently, my home directory on my work computer contains these directories:

     3D Objects          Contacts            Desktop             Digital Signature
     Documents           Downloads           eclipse             eclipse-workspace
     Favorites           Links               Music               OneDrive
     Pictures            Saved Games         Searches            Videos

Each time you create a new project in Eclipse, the IDE creates a new directory in the eclipse-workspace directory. For example, one absolute path to one of my Eclipse projects is C:\Users\dwharder\eclipse-workspace\Fast_sin\. While it is perfectly acceptable to use spaces in the names of directories and files, it is somewhat ever so slightly easier in a command-line interface if directory names and files do not have spaces, and thus I replace those spaces with an underscore.

Tree or hierarchical structures

The sub-directories within a given directory are also sometimes referred to as child directories while the directory within which a given directory appears is called the parent directory of the given directory. You can see that directories form a branching pattern, where each directory can contain zero or more sub-directories. As such, this branching pattern can be ssen as being similar to that of a tree or a hierarchy within an organization.

This branching pattern can usually be viewed in one of two means:

  • an inverted tree structure with the root directory at the top, and
  • a vertical depth-indent list with all contents of a given directory being listed immediately below the directory name at one deeper level of indentation.

For example, on my computer, some of the directories in my directory structure on C:\ look like:

On the other hand, you open a File Explorer in Windows (and similar programs in other operating systems), the left-hand panel contains a vertical depth-indented list that is collapsble, meaing you can expand or hide the contents of any given directory:

In the File Explorer program, there is exactly one directory, the contents of which is displayed on the right-hand panel of the window. This directory is called either the current directory or the working directory.

File extensions

The purpose of a file is often described by an extension. For example, JPEG files have the extension .jpg or .jpeg and C++ source files have the extension .cpp. In Windows, executable files have the extension .exe. By default, Windows 10 does not show the extensions. To force Windows 10 to show the extensions of all files, open the Control Panel application and select Appearance and Personalization. From here, select the File Explorer Options which opens a File Explorer Options dialog. Choose the View tab and then in the Advanced settings: list, unselect the Hide extensions for known file types and then select Apply or if you are finished, select OK.

Three types of files

There are many different types of files, but they can generally be categorized under one of three classifications:

  • A file that contains only ASCII or Unicode characters is described as a text file. All of your source files will be text files. There are many editors you can use to access, manipulate and save text files.
  • A file that contains data that cannot be interpreted as characters is called a binary file. The interpretation of a binary file depends on how it was created. Images, for example, are binary files, as are compressed files using programs like zip.
  • A special category of binary files are executable files, meaning files where the bits represent instructions to the processor.

In addition to source code like the .cpp files

Three variations on a theme

If you are using a Windows computer, you can either use a Windows command-line interface called the Command Prompt or you may open a Cygwin64 Terminal. If you are using Unix, Linux or MacOS, you will use the command-line interface called a Terminal. Select the interface you wish to use from the left-hand menu.