CS 1440 Lab 1
Activity 1-4: Compiling a C++ program
- Learning how to compile a C++
program on cs.
- Learning how to run an
- Learning what an unsuccessful
compile looks like.
The Unix application on cs that we use
to compile C++ programs is called "g++". When using the g++
application, you must tell it what C++ program you want compiled. The
executable program created by the compiler is named "a.out" by
default. Let's try it.
- Make sure you are in
your 1440/Lab1 directory.
- Use the "ls"
command to make sure you have the C++ program file named
- Notice that there is
no file named a.out
- Type: g++
- Now list your files
and notice that a.out was created.
- Tell Unix to run your
application program by typing:
That's it! Make sure to demo running your executable program to your
Now let's see what g++ does if there is an error in
the C++ program file.
- Edit the hello.C file
- Remove the ‘i’ character
after pound, ‘#’, character.
- Write out the file.
- Compile it
- Notice that g++
responds with numerous messages about problems it discovered. Notice also that one small change
can make the g++ compiler complain quite a lot!
Fix your hello.C file so that it is correct again. Compile it again and make sure it works by running your