CSCE 121: Introduction to Program Design and Concepts
Lab Exercise 0
Objective
The aim of this little assignment is to make sure that everyone: (i) can find their lab section and meets their lab TA; (ii) can get up and running connecting to university machines; (iii) can compile a simple C++ program. This stuff needs to be properly squared away so that we can proceed onto the interesting things.
Claim your CSE account
Instructions are here: Claiming your Computer Science accounts.
Connect to the VPN
If you are off-campus, you need to use a VPN to access the CSE Unix server. Information is here: VPN Options. Or simply visit https://connect.tamu.edu.
Mapping your H drive
The H drive allows you to access your files from any CSE Unix Server. Thus, any time you write a program, you can save it in the H drive and access it from the CSE Unix server.
- Instructions to map your H drive on Windows can be found here.
- For Mac, you can follow the instructions here.
Connect to build.tamu.edu
This is the CSE Unix server.
-
On Windows, you need to use PuTTY, which is already installed
in the open access lab computers. If you want to install PuTTY on your
personal computer, get it from here.
- Once you have installed and opened PuTTY, type build.tamu.edu in the Host Name (IP address) textbox.
- You can save time and save the session by giving it a name (e.g. build.tamu.edu) in the Saved Sessions textbox and then clicking Save.
- Next click on the Open button and you will see an Alert Window. Click Yes and then type your NetID and password. (Note that, due to an old quirk in Unix, when typing your password, it won't show your characters as you type them.)
- If you want to explore folders and files you have in the H drive, you can find a guide to use the Basic Unix commands here: Basic UNIX Commands.
- Note: Each time you open PuTTY you can simply click the session name (e.g. build.tamu.edu) and click Load.
- For Mac, you can connect to build.tamu.edu with a terminal (command line) window. Instructions are here: Mac Guide. (You may have to use the following location //coe-fs.engr.tamu.edu/ugrads/ instead of the one mentioned in the guide.)
Compile and run programs
- Open your preferred text editor and create a file named
hello_world.cpp with the following contents:
#include <iostream> using namespace std; int main() { cout << "Hello, world!\n"; return 0; }
- To compile the program, type the following command:
g++ hello_world.cpp
- If you got no errors, this will make an executable file
called a.out in the current directory.
To execute the program, type the following command:
./a.out
- If you got any errors, then check your code carefully, make appropriate changes in the hello_world.cpp file and try again.
-
The name a.out is rather ugly. The unix command mv, used like this, will rename the file:
mv a.out better_named_program
It can be tedious for every program to be called a.out only until we rename it. If you want your executable file to have a different name, say, hello_world (with no extension), you can append -o hello_world to the compile command, like this:g++ hello_world.cpp -o hello_world
Post to the Piazza Discussion
If you haven't already, go to https://piazza.com/tamu/spring2019/csce121501504 and sign-up.
There is a folder called "Introductions" — go and add a post within this folder, either reply to an existing post, or add a new one. In the post put (1) your name, (2) the section you are in, 501–504, and (3) some interesting, or not-so-interesting, fact about yourself (e.g. what interesting thing did you get up to over the winter break? What are your hobbies? Post a link you like, etc.