Download presentation
Presentation is loading. Please wait.
1
Precept I : Lab Environment, Unix, Bash, Emacs
2
Lab Environment (Linux)
Lab machines are administered by TA IP address range (12 machines) ~ Use SSH protocol to communicate with the lab machine PuTTY (Windows) Terminal (Mac OS) ID Your student number Password
3
Cygwin Provide Linux-like environment in Windows Install Cygwin
Install Cygwin Download & run setup.exe Choose any URL to download files
4
VMware Player Run another OS (Linux, Windows, etc.) on top of main OS
Install VMware Download VMware Player for Windows 32-bit and 64-bit Run downloaded file
5
VMware Player Download Linux (Ubuntu) image file
Install Linux on VMware Click on “Create a New Virtual Machine” Click on “Browse…” button Add image file downloaded from website Insert information : username, password, etc. Press “Play virtual machine” button
6
Accessing from Outside KAIST
Require virtual private network (VPN) program At first run, use Internet Explorer! kvpn.kaist.ac.kr Log in Press Start
7
Change Password on All Machines!
Connect to the machine with default ID & PASSWORD Type “passwd” In response to “(current) UNIX password:”, type current password In response to “New password:”, type new password. In response to “Retype new password:”, type new password again. Reminder Each machine does not share files It is your responsibility to back up your files Keep the code locally Use the lab machines only for testing and debugging
8
Unix and Bash
9
Bash Commands For details, read the handout Most useful commands
Description man <function name> open manual page cd <directory name> change directory ls [-al] list files in the directory mkdir <directory name> make directory rmdir <directory name> remove directory less/cat/more <file name> print file content cp <source> <target> copy source file to target mv <source> <target> rename source file to target
10
Emacs Popular editor Already installed in lab machines
Integrated with GCC compiler driver & GDB debugger Already installed in lab machines emacs test.c
11
Emacs Hotkey Hotkey Description Ctrl-k cut line Ctrl/alt-w
cut/copy region Ctrl-y paste copied/cut region Ctrl-x Ctrl-s save file Ctrl-s/r <string> search/recursive string Ctrl-x Ctrl-f <file> open file Ctrl-x 2/3 Split window vertically/horizontally Ctrl-x o move to different window Ctrl-x 1/0 close other/this window Ctrl-x u undo Ctrl-g abort command Ctrl-x Ctrl-c close emacs
12
gcc209 –E hello.c > hello.i
Building C Programs hello.c Source code C language Contains preprocessor directives hello.i Contains declaration of printf() Missing definition of printf() #include <stdio.h> int main(void) { printf("hello, world\n"); return 0; } Preprocess gcc209 –E hello.c > hello.i C Preprocessor … int printf(char *format, …) int main(void) { printf("hello, world\n"); return 0; }
13
Building C Programs hello.s Source code Assembly language
Missing definition of printf() Compile gcc209 –S hello.i C Compiler .section .rodata cGreeting: .asciz “hello, world\n” .section .text .global main .type main: puchl %ebp movl %esp, %ebp pushl %cGreeting call printf addl $4, $esp movl $0, %eax movl %ebp, %esp popl %ebp ret
14
Building C Programs hello.o hello Object code Machine language
Missing definition of printf() hello Assemble gcc209 –c hello.s Assembler … … Link gcc209 hello.o –lc -o hello Linker … gcc209 is an abbreviation for gcc –Wall –ansi –pedantic –m32 –march=i386 Shortcut: gcc209 hello.c –o hello
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.