编程代考 LAB01 – Get familiar with C programming with gcc – cscodehelp代写

PowerPoint Presentation

LAB01 – Get familiar with C programming with gcc

Copyright By cscodehelp代写 加微信 cscodehelp

COMP1411: Introduction to Computer Systems
Dr. Xianjin XIA
Department of Computing
The Polytechnic University
Spring 2022
These slides are only intended to use internally. Do not publish it anywhere without permission.

Objectives
To get familiar with C programming with gcc
Learn to login the Apollo server with SSH clients
Learn to upload files to Apollo with FTP clients
Learn to compile a C program with gcc

Review of LEC01: to get the first impression on compiling process and data types
Try to decompile the “hello” program by yourself with objdump
Revisit the “X2 < 0” problem Revisit the “(x+y)+z ≠ x+(y+z)” problem Remote login Apollo Login a remote server Apollo is a server machine with a CentOS Linux operating system installed The operating system allows remote access with the SSH protocol More on SSH: https://en.wikipedia.org/wiki/SSH_(Secure_Shell) Usually, we use a client software, e.g., PuTTY, to remotely access a server Remote server login will be very common for programming exercises in this online learning period Your Computer gcc, gdb, etc. Remote login Apollo For Windows Option 1: Use the PuTTY client software https://www.putty.org/ Option 2: Use command prompt Open “cmd”, and input command ssh –l uid csdoor.comp.polyu.edu.hk (replace uid with your COMP ID) Option 3: Use “Chrome explorer + Secure Shell extension” Install Chrome, add the “secure shell extension” For Mac OS Option 1: PuTTY for MacOS is not provided, but you can search online for other SSH client software Option 2 and 3 for Windows also apply for Mac OS Option 2: launchpad, search for “terminal” We will use PuTTY on Windows for demonstration in our labs Remote login Apollo Open PuTTY and connect Host Name: csdoor.comp.polyu.edu.hk Port: 22 Connection Type: SSH Remember to save the session to avoid input again next time Input a name in the “Saved Sessions” field, and click “save” Remote login Apollo Login with COMP ID Input COMP ID -> input COMP password
Note that when entering password, nothing is shown on the screen, keep typing and make sure to input the correct password
Once successful, you will come to the host selection step
Input “apollo” and press ENTER to select the first server

Remote login Apollo
Login with COMP ID
Input your password again, and you are done!

Upload files to Apollo
Upload files
Usually, we use the FTP protocol to transfer files between your own computer and a remote server
For simple operation, we typically use a FTP client
We use FileZilla for both Windows and Mac OS
https://filezilla-project.org
Of course, any other FTP clients also suffice

Upload files to Apollo
Open FileZilla, and input connection information
Host: csdoor.comp.polyu.edu.hk; Username: your COMP ID
Password: your COMP password; Port: 22
Then click “Quickconnect”, and your connection will be remembered by the software so that you don’t have to input again next time

Upload files to Apollo
File management on the server and file transfer between your computer and the server, with drag and drop, right click, etc.
Make a new directory “COMP1411” and put everything of this course here, to avoid mix-up with other courses

Navigate the file system on your own computer

Navigate the file system on the remote server
drag & drop

Compile and Decompile “hello”
OBJECTIVE: to learn how to compile a program and get the very first impression on the compilation process
Create a new directory “LAB01” under the “COMP1411” directory
Copy the hello.c file to “LAB01” with File and run the program
gcc hello.c –o hello
Compile the program again with intermediate files, and decompile
gcc –save-temps hello.c –o hello
objdump –D hello.o > hello-obj-dump.txt
objdump –D hello > hello-exe-dump.txt
Transfer all newly generated files back to your own computer, and view the files with any text editor on your computer

Revisit the “X2 < 0” problem OBJECTIVE: to get the very first impression on data types Copy the file “integer.c” to directory “LAB01” Compile and run the program gcc interger.c –o integer Guess what is the reason for the “X2 < 0” phenomenon? See the limits of integers Copy the file “intlimit.c” to directory “LAB01” Gcc –std=c99 intlimit.c –o intlimit ./intlimit Even though, for now, you still cannot precisely explain why, remember what you’ve done and seen, and let’s make it clear in the next lecture Revisit the “(x+y)+z ≠ x+(y+z)” problem OBJECTIVE: to get the very first impression on data types Copy the file “double.c” to directory “LAB01” Compile and run the program gcc double.c –o double Guess what is the reason for the problematic phenomenon? Let’s go further Copy the file “double2.c” to directory “LAB01” gcc double2.c –o double2 What do you see? Remember it, and let’s make it clear in LEC03 More on the programming environment If you think editing and compiling a program is too inconvenient remotely on Apollo, there are other options Installing a gcc compiling environment on Windows/Mac OS MinGW-64 for Windows: https://sourceforge.net/projects/mingw-w64 HomeBrew for Mac OS: https://brew.sh/ Install a Linux on a virtual machine or on a bare-metal Linux operating system family has the best support for gcc-based development environment Virtual machine solution: VirtualBox + Ubuntu Linux /docProps/thumbnail.jpeg 程序代写 CS代考 加微信: cscodehelp QQ: 2235208643 Email: kyit630461@163.com

Leave a Reply

Your email address will not be published. Required fields are marked *