140 likes | 257 Views
Editing & Compiling: UNIX vs. IDE and an Intro to Architecture. Outline. Announcements: Homework I on web, due Fri., 5PM by e-mail Basic computer architecture Creating code Compiling code Integrated Development Environments. Development Process. Design Specification Build Prototype
E N D
Editing & Compiling: UNIX vs. IDE and an Intro to Architecture
Outline Announcements: Homework I on web, due Fri., 5PM by e-mail Basic computer architecture Creating code Compiling code Integrated Development Environments
Development Process Design Specification Build Prototype Implementation: write the code Build: Get it to compile and run Debug I: find and fix syntax errors Debug II: find and fix semantic errors (testing) Improve performance through tuning or re-design
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 prog for (j=0;j<5){ : } #($**@)@__!( {ø∆˜ß√ˆœπ˚ Œ¨Ω√≈˜¡£¢∞ cc prog.c -oprog
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
Compiling & Linking prog.c prog prog.o printf.o for (j=0;j<5){ sin(x[j]); } #($**@)@__!( {ø∆˜ß√ˆœπ˚ Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ #($**@)@__!( Œ¨Ω√≈˜¡£¢∞ sin.o cc prog.c -oprog Transnslation Link
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
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!
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
Basic Development on UNIX Compiling on UNIX cc <options> <code files> -o<executable name> 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 <name>: link to library lib<name>.a -w: inhibit warnings
Basic Development on UNIX Running the program just type the name (assumes . is in path) if that doesn’t work, type ./name
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 /<option rather than -<option>
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
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