Professional Documents
Culture Documents
Content
Linux Kernel GNU tools Commercial tools Languages & Portability Assembly and C
Linux C++ Make, build, install Perl, Python, PHP GUI frameworks
Linux Programming
Linux Programming
Linux Programming
Group Discussion
1.
2.
3.
4.
5.
Programming, Art or Science? Interpreted vs Compiled Languages Compiler Machines Web Programming Mobile Programming
Linux Programming
Extreme Programming
Linux Programming
Linux Programming
Software Projects
System:
Kernel or driver modules Server (web, file, email)
Applications
Local
Tools or Utilities
Installer Compiler
Linux Programming 7
Distribution
Target Audience
Internal Use CD Download from Web site
Frequency
One time Progressive Releases
Linux Programming 8
Case Study
Daemons
Run in the background Have no controlling terminal Use the system log to report any messages Often run from the boot scripts
Linux Programming 10
C++
Linux Programming
11
C++ History
Began as enhancements to C,
adding classes virtual functions operator overloading multiple inheritance templates exception handling
Linux Programming 12
C++ Uses
Highly Portable!
Most Hardware Support Most Commercial Tools Most Applications
Linux Kernel!
Linux Programming
13
kernel.org
Linux Programming
14
Linux Architecture
Linux Programming
15
Kernel Subsystems
Linux Programming
16
Linux Programming
17
Android Architecture
Linux Programming
18
Linux Programming
19
Kernel configuration
Defines what features to include in the kernel: Stored in the .config file at the root of kernel sources. Most useful commands to create this config file: make [xconfig | gconfig | menuconfig | oldconfig] To modify a kernel in a GNU/Linux distribution: config files usually released in /boot/, together with kernel images: /boot/config-2.6.17-11-generic The configuration file can also be found in the kernel itself: > zcat /proc/config.gz (if enabled in General Setup -> Kernel .config support)
Linux Programming
20
make xconfig
Includes a File browser: easier to load configuration files New search interface to look for parameters
Linux Programming
21
Linux Programming
22
Linux Programming
23
# # CD-ROM/DVD Filesystems # CONFIG_ISO9660_FS=m CONFIG_JOLIET=y CONFIG_ZISOFS=y CONFIG_UDF_FS=y CONFIG_UDF_NLS=y # # DOS/FAT/NT Filesystems # # CONFIG_MSDOS_FS is not set # CONFIG_VFAT_FS is not set CONFIG_NTFS_FS=m # CONFIG_NTFS_DEBUG is not set CONFIG_NTFS_RW=y
Section name
Linux Programming
25
make menuconfig
make menuconfig Useful when no graphics are available. Pretty convenient too! Same interface found in other tools: BusyBox, buildroot...
Linux Programming
26
Linux Programming
27
Linux Programming
28
Linux Programming
29
Compiling Tips
make -j <n> Runs several targets in parallel Use it by adding a ccache prefix to the CC and HOSTCC definitions in Makefile CC = ccache $(CROSS_COMPILE)gcc HOSTCC = ccache gcc
Linux Programming
30
View the full (gcc, ld...) command line: make V=1 Clean-up generated files (to force re-compiling drivers): make clean Remove all generated files Caution: also removes your .config file! make mrproper Also remove editor backup & patch reject files: make distclean
Linux Programming
31
Generated files
What gets created when you run the make command
vmlinux Raw Linux kernel image, non compressed. arch/<arch>/boot/zImage (default image on arm) zlib compressed kernel image arch/<arch>/boot/bzImage (default image on i386) Also a zlib compressed kernel image. Caution: bz means big zipped but not bzip2 compressed!
Linux Programming
32
Linux Programming 33
Linux Programming
34
All the files in this directory are text files. Don't hesitate to have a look by yourself!
Linux Programming 35
Linux Programming
36
Linux Programming 37
Linux Architecture
Applications,
GNU tools,
Shells
User
System Call Interface VFS
Net Sockets TCP/IP driver
IDE, SCSI Floppy driver
Mem Mgr
Proc Mgr
Kernel
NIC driver
HD
FD
Linux Programming
NIC
Hardware
38
Since Linux follows the UNIX model, and in UNIX everything is a file, users talk with device drivers through device files Device files are a mechanism, supplied by the kernel, precisely for this direct User-Driver interface. Koolchar is a character device, & thus the user talks to it through a character device file The other common kind of device file is a block device file
Linux Programming
39
NET Subsystem
Linux Programming
40
GNU Tools
Make
AutoMake AutoConf
Libtool
Linux Programming 41
GNU Architectures
Alpha ARM Atmel AVR Blackfin PA-RISC PDP-11 PowerPC R8C/M16C/M32C
Linux Programming
42
A Simple Makefile
Linux Programming
43
A Not-So-Simple Makefile
Linux Programming
44
Hello World in C
Linux Programming
45
Hello World
vi `hello.c #include <stdio.h> main() { printf("Hello world!\n"); } `Makefile.am bin_PROGRAMS = hello hello_SOURCES = hello.c
Linux Programming
46
% make
source='hello.c' object='hello.o' libtool=no \ depfile='.deps/hello.Po' tmpdepfile='.deps/hello.TPo' \ depmode=gcc3 /bin/sh ./depcomp \ gcc -g -O2 -o hello hello.o
Linux Programming 47
Software Building
Hands-on Lab 1
Linux Programming
48
Commercial Tools
IBM
Intel
C++ Compiler Professional for Linux Intel Parallel Studio XE
Zend
http://framework.zend.com/
Linux Programming 49
Linux Programming
50
Powerful Software!
SugarCRM Moodle.org
Linux Programming 51
Linux Programming
52
Platforms
Linux Programming
53
2 Tiers:
Web Logic
Linux Programming
54
Scripting
Perl Python PHP
Linux Programming
55
Perl
Developed by Larry Wall [a linguist working as a systems administrator for NASA] in 1987 as a general-purpose Unix scripting language to make report processing easier
Linux Programming
56
Perl Code
#!/usr/local/bin/perl ## ## printenvdemo CGI program which just prints its environment ## # print "Content-type: text/plain\n\n"; foreach $var (sort(keys(%ENV))) { $val = $ENV{$var}; #!/usr/local/bin/perl $val =~ s|\n|\\n|g; print "Hi there!\n"; $val =~ s|"|\\"|g; print "${var}=\"${val}\"\n"; }
Linux Programming
57
Perl Evaluation
Multiplatform
Open Source Free to use
Early start,
Extensive library!
Software Building
Hands-on Lab 2
Linux Programming
59
Python
General-purpose, high-level programming language which emphasizes code readability It claims to combine "remarkable power with very clear syntax with fun Red Hat installer is written in Python!
Python Code
print 'Hello, world! name = raw_input('What is your name?\n') print 'Hi, %s.' % (name) my_list = ['john', 'pat', 'gary', 'michael'] for i, name in enumerate(my_list): print "iteration %i is %s" % (i, name)
Linux Programming
61
Python Evaluation
Multiplatform Open Source Free to use VERY popular
Software Building
Hands-on Lab 3
Linux Programming
63
PHP
Server-side scripting language originally designed for web development to produce dynamic web pages
PHP can be deployed on most web servers and almost every OS free of charge! Its embedded into an HTML source document, rather than calling an external file to process data
Linux Programming
64
PHP Code
class Person { public $firstName; public $lastName; public function __construct($firstName, $lastName = '') { //Optional parameter $this->firstName = $firstName; $this->lastName = $lastName; public function greet() { return "Hello, my name is " . $this->firstName . " " . $this->lastName . "."; } public static function staticGreet($firstName, $lastName) { return "Hello, my name is " . $firstName . " " . $lastName . "."; } }
Linux Programming
65
Linux Programming
66
PHP Evaluation
Multiplatform Open Source Free to use VERY popular Extensive libraries!
Software Building
Hands-on Lab 4
Linux Programming
68
Linux Programming
69
Summary
Linux Kernel GNU tools Commercial tools Languages & Portability Assembly and C
Linux C++ Make, build, install Perl, Python, PHP GUI frameworks
Linux Programming
70