210 likes | 465 Views
CSE 1222. Linux. CSE User Name. Your CSE user name Assigned by the CSE department It is NOT the same as your OSU user name You should have received your CSE user name in e-mail sent to your OSU account If you don’t have your user name, see me. Windows Password.
E N D
CSE 1222 Linux The Ohio State University
CSE User Name • Your CSE user name • Assigned by the CSE department • It is NOT the same as your OSU user name • You should have received your CSE user namein e-mail sent to your OSU account • If you don’t have your user name, see me The Ohio State University
Windows Password • Your starting Windows password is: # # # # xxp! • # # # # are the last four digits of your OSU ID number, xx are your first and last initials (lower case), and don’t forget the p and ! For example, if John Smith’s OSU ID number is 123456789, then his starting password is: 6789jsp! The Ohio State University
This is what your screen looks like when you log in to your CSE Windows account The Ohio State University
Click on the icon on the left (not the one on the right) to switch to CSE Unix The Ohio State University
Your CSE user name and password for Unix is the same as your username and passoword for Windows The Ohio State University
Right click in the background and then select “Open in Terminal” to create a terminal window The Ohio State University
The UNIX command prompt is now waiting for you to type in a command to execute • You want to familiarize yourself very quickly with the most common UNIX commands (ls, cp, mkdir, etc.) The Ohio State University
Select the terminal window and type: xemacs first.cpp & at the command line to create your first program The Ohio State University
Program first.cpp Select the xemacs window and enter the following text exactly as shown below: // File: first.cpp // Created by: Your name // Created on: Jan. 3, 2012 #include <iostream> using namespace std; int main() { cout << "My first program in CSE 1222!" << endl; cout << "My parents will be so proud." << endl; return 0; } The Ohio State University
Select the “File” menu and “Save first.cpp” to save the file The Ohio State University
Select the “File” menu and “Exit XEmacs” to leave emacs The Ohio State University
Select the terminal window and type: g++ first.cpp a.out at the command line to compile and run your first program The Ohio State University
Important Note: If you forgot the “&” in “xemacs first.cpp &” and did not exit emacs, then nothing will happen when you type the command “g++ first.cpp”. • Your terminal window is waiting for you to close the emacs window • Select the “File” menu and “Exit XEmacs” to leave emacs. The Ohio State University
Compiler (g++) errors If you did not type the program in exactly as in slide 10, you may get an error message after typing “g++ first.cpp”. For example, if you forgot quotation marks on line 10, the following would happen: > g++ first.cpp first.cpp:10:39: warning: missing terminating " character first.cpp:10: error: missing terminating " character first.cpp: In function ‘int main()’: first.cpp:10: error: ‘My’ was not declared in this scope first.cpp:10: error: expected ‘;’ before ‘first’ > • Is this a syntax error or logical error? Why? • Error messages are often hard to understand; • The most useful part of the error message is the line number (in this case 10) which tells you where the compiler detected the error. The error is usually in this line or in the line just preceding it. • Try to correct your program to match exactly the code in slide 10. The Ohio State University
Type: ls to list the files in your directory. The computer should list: a.out first.cpp The Ohio State University
Copying a file Type: cp first.cpp second.cpp to create a copy of first.cpp which is called second.cpp Type: ls to again list the files in your directory The computer should now list: a.out first.cpp second.cpp The Ohio State University
Creating second.cpp Type: xemacs second.cpp & to edit the program second.cpp. Be sure to remember the “&” • Modify the lines: cout << "My first program in CSE 1222!" << endl; cout << "My parents will be so proud." << endl; in second.cpp so that they print your name and your favorite food. • Modify only the text between the double quotation marks • Be sure not to delete the double quotation marks • Select the “File” menu and “Save second.cpp” to save the file • Select the “File” menu and “Exit ” to save the file The Ohio State University
Type the following two commands (at two separate prompts of course): g++ second.cpp a.out to compile and run the program second.cpp The Ohio State University
Tutorials • UNIX • http://www.cse.ohio-state.edu/~weide/sce/reference/unix • XEmacs • http://www.cse.ohio-state.edu/~weide/sce/reference/xemacs The Ohio State University