Presentation is loading. Please wait.

Presentation is loading. Please wait.

Editing & Compiling: UNIX vs. IDE and an Intro to Architecture.

Similar presentations


Presentation on theme: "Editing & Compiling: UNIX vs. IDE and an Intro to Architecture."— Presentation transcript:

1 Editing & Compiling: UNIX vs. IDE and an Intro to Architecture

2 Outline Announcements: –Homework I on web, due Fri., 5PM by e- mail Basic computer architecture Creating code Compiling code Integrated Development Environments

3 Development Process 1.Design 2.Specification 3.Build Prototype 4.Implementation: write the code 5.Build: Get it to compile and run a) Debug I: find and fix syntax errors b) Debug II: find and fix semantic errors (testing) 6.Improve performance through tuning or re- design

4 Build Process Write code Pass to compiler –Compiler creates an “executable”--a binary file with low- level instructions equivalent to your high-level program Run the executable prog.c for (j=0;j<5){ : } prog #($**@)@__!( {ø∆˜ß√ˆœπ˚ Œ¨Ω√≈˜¡£¢∞ cc prog.c -oprog

5 Compiling & Linking Compiling consists of two steps: –Translating high-level language to machine code Many ways to translate same commands Some ways may have better performance –Linking bits of machine code together to form an executable Even simple programs are not self contained –You can call routines like “sin,” “printf”, or “write;” but you don’t have to include code for these functions in your program Rather, “built-in” functions have already been translated and are stored in object files somewhere on the system Compiler must get the machine code and bundle with your executable

6 Compiling & Linking prog.c for (j=0;j<5){ sin(x[j]); } prog #($**@)@__!( {ø∆˜ß√ˆœπ˚ Œ¨Ω√≈˜¡£¢∞ cc prog.c -oprog Transnslation prog.o #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ Link printf.o #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ sin.o

7 Basic Development on UNIX A note on UNIX: –UNIX is a powerful, elegant, and simple OS –For many years, UNIX systems were THE systems for scientific work –Windows is eating away, but UNIX systems are still common –I will typically discuss UNIX tools first and then examine analogous tools on Windows –The UNIX tools are typically more general and were the inspiration for the Windows analogs

8 Basic Development on UNIX First thing we need is a text editor –vi--terminal editor. Very basic editor that you control solely through the keyboard (no mousing) useful for fixing small bugs, editing input files I wouldn’t want to write more than a few lines, though –Emacs--classic UNIX word processor. Lots of people love emacs, but I’m not one of them –NEdit--world’s greatest text editor Mac/PC like interface, good syntax highlighting (can be easily modified and customized) Efficient searching/replace (possible to use regular expressions) column cut and paste!

9 Basic Development on UNIX Next, we need to compile –Compilers are specific to programming languages (sort of) Operating Systems/processors (definitely) –For a given language/system combination there are often several compilers differ by price: GNU vs. commercial differ by performance

10 Basic Development on UNIX Compiling on UNIX –cc -o –compiler name might change (gcc, cc, f77, f90), but the format is usually the same –typical options: -o : name the executable (otherwise, a.out) -O : perform some basic performance optimizations -O2: perform some more dramatic optimizations -c: compile to object code (don’t link) -g: enable debugging -l : link to library lib.a -w: inhibit warnings

11 Basic Development on UNIX Running the program –just type the name (assumes. is in path) –if that doesn’t work, type./name

12 Basic Development on Windows Editors –Free stuff like Notepad, Wordpad –NEdit –MSWord (but why?) Compilers –most will work from a DOS prompt in a UNIX-like fashion –key difference is that you use /

13 Basic Development on Windows Although you can do things from a DOS prompt, most Windows programming is done in an Integrated Development Environment (IDE) –CodeWarrior –VisualStudio –Also ProjectBuilder (Mac), KDev (Linux) What are they integrating? –combine editor, compiler, and debugger

14 Much easier to use, just edit and push a button to compile and run –can often click on compiler error messages and go right to the line –set compiler options through menus Main disadvantage: disconnected from compiler –often, finding compiler options is hard and usually just like the command line –documentation can be poor IDEs


Download ppt "Editing & Compiling: UNIX vs. IDE and an Intro to Architecture."

Similar presentations


Ads by Google