33
1 Getting Started with C++ Part 2 Linux

1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Embed Size (px)

DESCRIPTION

About Circe All USF students have access to a Linux system known as Circe. Try logging in with your USF NetID. (Details follow.) If unsuccessful, you should be able to get access at rc.usf.edurc.usf.edu If unsuccessful there, please contact the USF IT Help Desk

Citation preview

Page 1: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

1

Getting Started with C++

Part 2Linux

Page 2: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

2

Getting Started on Linux

Now we will look at Linux.

See how to copy files between Windows and Linux

Compile and run the “Hello, World” program on Linux.

Try out a very simple editor on Linux.

Page 3: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

About Circe All USF students have access to a Linux

system known as Circe.

Try logging in with your USF NetID. (Details follow.)

If unsuccessful, you should be able to get access at rc.usf.edu If unsuccessful there, please contact the USF

IT Help Desk. 974-1222

3

Page 4: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Connecting to Circe Use an SSH terminal client program

to connect to Circe. Recommended client program is

PuTTY Can download from http://www.putty.org/

You will also need an SSH file transfer program.

Recommended client program is WinSCP Can download from

https://winscp.net/eng/download.php4

Page 5: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Connecting with PuTTY

5

Click Open

Page 6: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Using Circe

6

Your Net ID

Your Net ID Password

Command Prompt

Page 7: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Create a Test Directory

7

Page 8: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

8

Copying a File to Circe Use an SSH file transfer program to

copy the C++ source file to your test directory on Circe. Recommended program: WinSCP

Page 9: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

WinSCP WinSCP gives you a window on your

desktop that looks and acts like a normal Windows folder.

You can drag and drop between the WinSCP window and a Windows folder in either direction.

9

Page 10: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

10

Connecting to Circe with WinSCP

Click Login

Page 11: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Connected to Circe

11

Page 12: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

12

Connected to Circe

Initially at your home directory.Your contents will be different.

Page 13: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

13

Open your test directory

Double click on your test directory to open it.

Page 14: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Open your project directory Locate and open your Visual Studio project

directory By default it is in your “My Documents” folder

under Visual Studio 2015\Projects C:\Users\Rollins\Documents\Visual Studio 2015\

Projects\hello Drill down to hello.cpp

14

Page 15: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Copy hello.cpp to Circe

15

Drag hello.cpp from your Visual Studio project directory window into the WinSCP window and drop it.

Page 16: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

Copy hello.cpp to Circe

16

Page 17: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

17

In the PuTTY Terminal Window

Look at the file

Compile and link

No response from g++ means that it was successful.Your executable file is named a.out

Page 18: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

18

Run It

Page 19: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

19

Creating a Source File on CirceDelete existing files. We will start from scratch.

nano is a very simple text editor.

Page 20: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

20

Creating a Source File on Circe

Whatever you type into this window will be written to the output file.

Page 21: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

21

Creating a Source File on Circe

Press Ctrl-o to write out the file.

Page 22: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

22

Creating a Source File on Circe

Press Enter to write contents of window to hello.cpp

Page 23: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

23

Creating a Source File on Circe

Press Ctrl-x to exit from nano.

Page 24: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

24

Exit from the Editor

Page 25: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

25

View the Source File

Page 26: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

26

Compile and Run

Page 27: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

27

The Manipulator endl

#include <iostream>

int main( void ) { std::cout << "Hello, World!";

std::cout << std::endl;

return 0;}

std::endl is not a character like '\n'It is an instruction to cout to start a new line.

Referred to as a manipulator.

Page 28: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

28

Multiple outputs with cout

#include <iostream>

int main( void ) { std::cout << "Hello, World!" << std::endl;

std::cin.get(); return 0;}

<< operators can be cascaded as many times as you wish.

Page 29: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

29

Input from the Keyboard#include <iostream>

int main( void ) { int a; int b; std::cout << "Enter two integers to compute their sum:" << std::endl;

std::cin >> a; std::cin >> b;

std::cout << "The sum of " << a << " and " << b << " is "; std::cout << a + b << std::endl;

return 0;}

Page 30: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

30

Input from the Keyboard

Page 31: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

31

Avoiding all those "std::"s#include <iostream>

using namespace std;

int main( void ) { int a; int b; cout << "Enter two integers to computer their sum:" << endl;

cin >> a; cin >> b; cout << "The sum of " << a << " and " << b << " is "; cout << a + b << endl;

return 0;}

Page 32: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

32

Being More Selective#include <iostream>

using std::cin;using std::cout;using std::endl;

int main( void ) { int a; int b; cout << "Enter two integers to computer their sum:" << endl;

cin >> a; cin >> b; cout << "The sum of " << a << " and " << b << " is "; cout << a + b << endl; ... return 0;}

This is generally considered better practice.

Page 33: 1 Getting Started with C++ Part 2 Linux. 2 Getting Started on Linux Now we will look at Linux. See how to copy files between Windows and Linux Compile

33

Assignment

Before next class Be sure you can connect to Circe

and log in using your USF NetID. Do today’s examples for yourself

if you didn’t do them in class. Read Chapters 1 and 2.

End of Presentation