Tags:
create new tag
view all tags

Lab 0

Due January 23 at Midnight

Moodle link

Using the CS server for programming

Goal

Convert a program from a previous course to work on the CS server

Turn in

All code and example of run (Copy output and paste into a word document)

Links

Step 1 - Install software

Windows:

Mac
  • Install TextWrangler (Make sure to install 32-bit version, otherwise SFTP will not be available)

Step 2 - Create program File

Program:

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}
  • Open Notepad++ or TextWrangler
  • Paste in the code above
  • Save as hello.cpp. Make sure to select the file type to be a c++ program.

Step 3 - Copy to Server

With Notepad++

  1. In Notepad++ from the plugin menu open the NppFTP window
  2. in the NppFTP window open a connection to the cslab computer.
    • Use the cslab profile created from the instructions above (also here)
  3. You will start in your home directory (the folder with your username). Right click on your home directory, and select "Create new direcectory". Enter "project0"
  4. Upload the file you will to send ("hello.cpp") by selecting it's tab on the editor screen.
  5. Right click on the folder where you want the file to go in the NppFTP window (Project0)
  6. The file will now be uploaded to the "project0" directory.
With Textwrangler
  1. Make sure the file you want to copy is the one selected (hello.cpp)
  2. In the file menu select "Save to FTP/SFTP Server"
  3. For server put in "cslab.kenyon.edu
  4. Select "SFTP"
  5. Enter your username and password.
  6. The path should /home/students/username (your username)
  7. Save profile as cslab
  8. In the window (which should be at your home folder with your username) click "New Folder"
  9. Type in "Project0" and hit "Create"
  10. Click on "Save"
  11. The file should now be in your folder

Step 4 - Build and run your program

On Windows

  1. Log in with PuTTy
On Mac
  1. Open a terminal window (from your applications directory)
  2. Type "ssh username@cslab.kenyon.edu" (username is your username)
  3. You are now logged in to the server
Change directory to the project0 folder by typing "cd project0"

Do an "ls" command to list the files in the folder and make sure "hello.cpp" is there.

Build the program:
g++ -o hello hello.cpp

Run with "./hello"

Step 4

Port your own program

You goal is to select a program from Data Structures and get it to run on the our Linux Server. The program must be at least 100 lines of code.

If your program has multiple source files, copy them all, includeing the .h files, and then do the following:

Assume you have the following sources:

  • a.cpp
  • a.h
  • b.cpp
  • b.h
  • main.cpp Then:
user% g++ -c a.cpp 
user% g++ -c b.cpp 
user% g++ -c main.cpp 
user% g++ -o main a.o b.o main.o

Turn in

  1. Screen shoot(s) of your running program
  2. A brief writeup of your experience: What problems you encountered, what you learned.

Reference

Topic attachments
I Attachment History Action Size Date Who Comment
Microsoft Word filedoc EMACShandout.doc r1 manage 44.5 K 2016-12-19 - 05:05 JimSkon  
Microsoft Word filedoc UnixCHandout.doc r1 manage 66.5 K 2016-12-19 - 05:05 JimSkon  
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2017-01-19 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback