9
CprE 288 – Quick intro for compiling C in Linux http://class.ece.iastate.edu/cpre288 1 Instructor: Dr. Phillip Jones

CprE 288 – Quick intro for compiling C in Linux Instructor: Dr. Phillip Jones

Embed Size (px)

Citation preview

Page 1: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

CprE 288 – Quick intro for compiling C in Linux

http://class.ece.iastate.edu/cpre288 1

Instructor: Dr. Phillip Jones

Page 2: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Overview

• Compile C code in Linux• Linux Basics• Logging in to Linux boxes from off-campus

http://class.ece.iastate.edu/cpre288 2

Page 3: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Open a file

http://class.ece.iastate.edu/cpre288 3

At the command line prompt type:gedit file_name_to_create &

1) In this case I created a file called hw3_1.c2) The “&” is important. Without it you lose the prompt

Page 4: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Blank File

http://class.ece.iastate.edu/cpre288 4

A gedit window should openNotice the name of you fileon the tab

Page 5: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Add your C code

http://class.ece.iastate.edu/cpre288 5

In this case I justcopied from Word

Note: if you copy from Wordthe “ “ may not copy correctly. Just manually retype. See Next slide

Don’t forget to SAVE

Page 6: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Add your C code

http://class.ece.iastate.edu/cpre288 6

Page 7: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Compile your code and execute it

http://class.ece.iastate.edu/cpre288 7

Output of the program. Note: I have not put any code for my_strcat

Run the program thatyou just compiled called“test”

compile hw3_1.c and call the executable “test”.

Page 8: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

Linux Basics

• Some on-line tutorials and quick reference cards• http://www.ee.surrey.ac.uk/Teaching/Unix/• http://www.linuxdevcenter.com/excerpt/LinuxPG_quickref/linux.pdf

• How do I know where I am– pwd (tells you your current location, use this command often)

• What is in my current location– ls (list all the files and directors at this location)

• Changing directories– cd directory_name

• cd .. (takes you up one directory level)• cd ~ (takes you to your home directory)

• Making a new directory– mkdir new_directory_name

Page 9: CprE 288 – Quick intro for compiling C in Linux  Instructor: Dr. Phillip Jones

NX• NX is an application that allows you to access Linux machines from off campus.

– It is very lightweight and can be typically installed in less than 5 minutes• You can download NX 3.5 from the following links

– For Windows: http://it.engineering.iastate.edu/nx/ – After you install the NX client, make sure to install any additional fonts that are

available for your platform type. If you do not some application will not display properly

• You can try NX 4 (I have not tried this). You can download from:– https://www.nomachine.com/download– Note: You will need to adjust the setting to be compatible with NX 3.5.– https://www.nomachine.com/AR04J00627

• You can login to the following ISU Linux machines using your userID & password– Those listed here: http://www.it.eng.iastate.edu/remote– The ones that are NX capable will say NX in there list of applications.