Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Development Tools Presented by: Lisha Sterling Creating programs in Linux for Linux and the rest of the world...

Similar presentations


Presentation on theme: "Linux Development Tools Presented by: Lisha Sterling Creating programs in Linux for Linux and the rest of the world..."— Presentation transcript:

1 Linux Development Tools Presented by: Lisha Sterling lishevita@alwayssababa.com Creating programs in Linux for Linux and the rest of the world...

2 *Nix Way "This is the Unix philosophy. Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface." --Doug McIlroy

3 Developing on Linux For Linux Only Nativly compiled applications Usually C/C++ For the whole world Applications that run in a Web browser Interpreted languages like Perl, Python, Ruby Java No Need to get political about it Use the best tool for the job

4 Tools In Linux Darwinian process There are finches for every niche The most popular is not necessarily best for YOU. Start with popular, seek out your favorites Learn concepts Discover your needs and style

5 The End of the Line In *Nix-ish platforms, the end of a line is described by a new line (\n) In DOS-ish platforms, the end of a line is described by a carriage return (\r\n) This can cause nasty problems in compiling or viewing files in a text editor... Fix the problem with dos2unix: % dos2unix mycode.c

6 Editing Your Code Text Editors Kate gEdit Emacs Vi IDEs Kdevelop Eclipse CodeBlocks Anjuta... and soooo many more. Pick a tool and become expert with it

7 Internationalization Gettext Separates text and locale-specific info from code Allows for easier translation process Has implementations in C, C++, PHP, Python, Ruby, and more... How-to printf(_("My name is %s.\n"), my_name);

8 Code Repositories Subversion (svn) Bazaar Monotone Darcs Whether you are working on a project by yourself or with a world-wide team, keep your code in a repository! Version Control Saves Lives! (or at least butts...)

9 GNU Toolchain GNU make, for build and compilation automation; GNU Compiler Collection (GCC), with compilers for several languages GNU Binutils, linker, assembler and other tools GNU Debugger (GDB) GNU build system (autotools): Autoconf Autoheader Automake Libtool

10 Make Make is a utility for automatically building large applications. Files specifying instructions for make are called Makefiles. Make tracks which files have changed since the last time the project was built and invokes the compiler on only those source code files and their dependencies.

11 Makefile Structure # Comments use the hash symbol target: dependencies command 1 command 2... command n

12 Common Targets all install clean EXAMPLE: openssl.1: $(P2M) --section=1 openssl.pod > openssl.1.PHONY: install install: mkdir -p $(INSTALL_PREFIX)$(INSTALLTOP)/share/man/man1 mkdir -p $(INSTALL_PREFIX)$(INSTALLTOP)/share/man/man3 install -m 644 -p openssl.1 $(INSTALL_PREFIX)$(INSTALLTOP)/share/man/man1 install -m 644 -p crypto.3 $(INSTALL_PREFIX)$(INSTALLTOP)/share/man/man3 install -m 644 -p ssl.3 $(INSTALL_PREFIX)$(INSTALLTOP)/share/man/man3 rm -f $(MANS).PHONY: clean clean: rm -f $(MANS)

13 Autoconf Turns configure.ac into portable configure script that's the script you run when you do:./configure before make when you build an app

14 Automake Turns a makefile.am into a makefile.in Then Autoconf's configure file turns the makefile.in into the actual Makefile

15 Libtool...hides the complexity of using shared libraries behind a consistent, portable interface....is used with Autoconf and Automake

16 Compile It GCC – Gnu Compiler Collection Originally the ”Gnu C Compiler” This is basically THE Linux compiler. It's on nearly every Linux computer by default. Compiles C, C++, Java, Fortran, Pascal, Objective C and more.

17 Compiling C++ Files C++ source files conventionally use one of the suffixes.C,.cc,.cpp,.CPP,.c++,.cp, or.cxx C++ header files often use.hh or.H Preprocessed C++ files use the suffix.ii. GCC recognizes these files as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).

18 Using GCC gcc [flags] file1 [file2 [file3..]] [-o output_file] Example: gcc -g my_file.c -o my_prog (-g adds debug info)

19 More using GCC... ● -ansiThis flag tells the compiler to enforce ANSI C standards ● -pedantic More pedantic ansi, warnings for stuff you probably didn't mean. ● -Wall Show all reasonable warnings (there are more). ● -g Produce debug information, necessary for debugging. ● -llibrary Links to a standard library. Use -lm to load the standard math library. ● -c Compile or assemble the source files, but do not link. The compiler output is object files corresponding to each source file. ● -S Compile only; output assembly code. ● -E Pre-process only. Output pre-processed code. ● -Dmacro Define a macro, one can also use -Dmacro=val in order to assign a value for the macro. This will be used for preprocessing all files.

20 Java in GCC... gcj -c -g -O MyJavaProg.java gcj --main=MyJavaProg -o MyJavaProg MyJavaProg.o gcj -C -g -O MyJavaProg.java -i gcj -c -g -O MyJavaProg.class

21 Gnu Debugger (GDB) GDB can do four main kinds of things: Start your program, specifying anything that might affect its behavior. Make your program stop on specified conditions. Examine what has happened, when your program has stopped. Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another.

22 GDB Examples gdb prog.out debug prog.out gdb> run -v run the loaded program with the parameters gdb> bt backtrace (in case the program crashed) gdb> info registers dump all registers gdb> disass $pc-32 $pc+32 disassemble

23 Graphical Interfaces to GDB DDD Eclipse CDT Xcode debugger GDBtk/Insight "GUD mode" in GNU Emacs.

24 GNU Binary Utilities (binutils) is a collection of programming tools for the manipulation of object code in various object file formats. They are typically used in conjunction with GNU Compiler Collection, make, and GDB.

25 The binutils include these commands: as assembler ld linker gprof profiler addr2line convert address to file and line ar create, modify, and extract from archives c++filt demangling filter for C++ symbols

26 More Binutils... dlltool creation of Windows dynamic-link libraries nlmconv object file conversion to a NetWare Loadable Module nm list symbols in object files objcopy copy object files, possibly making changes objdump dump information about object files ranlib generate indexes for archives readelf display content of ELF files

27 More Binutils... size list total and section sizes strings list printable strings strip remove symbols from an object file windmc generates Windows message resources windres compiler for Windows resource files

28 Resources To build this presentation I used information from: Gilad Ben-Yossef's slides from another incarnation of this same presentation. Wikipedia (http://en.wikipedia.org) Man pages as seen on Kubuntu 7.04 My blog at http://theledgeofknow.blogspot.com


Download ppt "Linux Development Tools Presented by: Lisha Sterling Creating programs in Linux for Linux and the rest of the world..."

Similar presentations


Ads by Google