2. Contents
Using programming tools
Using GNU C Compiler (gcc)
Project management tools: make, automake, autoconf
Graphical DevelopmentTools
• IDEs and SDKs
• Kdevelp Client
Using popular languages
Java
Javascript
PHP
Python
Etc.
1-2
3. Using GNU C Compiler (gcc)
“GNU is an extensive collection of free software (383
packages as of January 2022), which can be used as an
operating system or can be used in parts with other operating
systems” (Wikipedia).
GNU cc (gcc) is the GNU project’s compiler suite. It
compiles programs written in C,C++, or Objective C.
The gcc features
Preprocessing
Compilation
Assembly
Linking
1-3
4. Example: gcc
1-4
1. /*
2. * Listing 3.1
3. * hello.c – Canonical “Hello, world!” program 4 4 */
4. #include <stdio.h>
5. int main(void)
6. {
7. fprintf(stdout, “Hello, Linux programming world!n”);
8. return 0;
9. }
$ gcc hello.c -o hello
$ ./hello
Hello, Linux programming world!
Complie and run
5. 1-5
$ gcc –E hello.c -o hello.cpp
$ gcc -x cpp-output -c hello.cpp -o hello.o
Stop compilation
after pre-procesing
See content of stdio.h and
compile to an object code
$ gcc hello.o -o hello
Link the object file
$ gcc killerapp.c helper.c -o killerapp
Use code from
other file
7. Project management using GNU make
Projects composed of multiple source files typically
require long, complex compiler invocations.
make simplifies this by storing these difficult command lines in
the Makefile
make also minimizes rebuild times because it is smart enough to
determine which files have changed, and thus only rebuilds files
whose components have changed
make maintains a database of dependency information for your
projects and so can verify that all of the files necessary for
building a program are available each time you start a build.
1-7
8. Writing Makefiles
A makefile is a text file database containing rules that tell
make what to build and how to build it.A rule consists of
the following:
A target, the “thing” make ultimately tries to create
A list of one or more dependencies, usually files, required to
build the target
A list of commands to execute in order to create the target
from the specified dependencies
Makefile
1-8
target : dependency dependency [...]
command
command
[...]
9. Makefile examples
It is the makefile for building a text editor imaginatively
named editor
1-9
1 editor : editor.o screen.o keyboard.o
2 gcc -o editor editor.o screen.o keyboard.o
3
4 editor.o : editor.c editor.h keyboard.h screen.h
5 gcc -c editor.c
6
7 screen.o : screen.c screen.h
8 gcc -c screen.c
9
10 keyboard.o : keyboard.c keyboard.h
11 gcc -c keyboard.c
12
13 clean :
14 rm editor *.o
To compile editor, you would simply type make in the directory where the makefile
exists.
Default target
Dependencies
Rules
Target
10. Makefile excercise
Examine the example Makefile 1 in
1-10
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
11. Makefile: variable
To simplify editing and maintaining makefiles, make allows
you to create and use variables.
To obtainVARNAME’s value, enclose it in parentheses and
prefix it with a $:
1-11
VARNAME = some_text [...]
$(VARNAME)
13. Environment,Automatic, PredefinedVariables
make allows the use of environment variables
make reads every variable defined in its environment and
creates variables with the same name and value
make provides a long list of predefined and automatic
variables, too.
1-13
AUTOMATIC VARIABLES
Variable Description
$@ The filename of a rule’s target
$< The name of the first dependency in a rule
$^ Space-delimited list of all the dependencies in a rule
$? Space-delimited list of all the dependencies in a rule that are newer thanthe
target
$(@D) The directory part of a target filename, if the target is in a subdirectory
$(@F) The filename part of a target filename, if the target is in a subdirectory
14. PREDEFINED VARIABLES
Variable Description
AR Archive-maintenance programs; default value = ar
AS Program to do assembly; default value = as
CC Program for compiling C programs; default value = cc
CPP C Preprocessor program; default value = cpp
RM Program to remove files; default value = “rm -f”
ARFLAGS Flags for the archive-maintenance program; default = rv
ASFLAGS Flags for the assembler program; no default
CFLAGS Flags for the C compiler; no default
CPPFLAGS Flags for the C preprocessor; no default
LDFLAGS Flags for the linker (ld); no default
1-14
15. Excercise
Examine the example Makefile 2 in
1-15
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
16. Implicit Rules
make comes with a comprehensive set of implicit, or
predefined, rules
1-16
1 OBJS = editor.o screen.o keyboard.o
2 editor : $(OBJS)
3 cc -o editor $(OBJS)
4
5 .PHONY : clean
6
7 clean :
8 rm editor $(OBJS)
the makefile lacks
rules for building
targets
(dependencies)
make will look for C source files named editor.c, screen.c, and keyboard.c,
compile them to object files (editor.o, screen.o, and keyboard.o), and finally,
build the default editor target.
17. Pattern Rules
Pattern rules look like normal rules, except that the
target contains exactly one character (%) that matches
any nonempty string.
1-17
%.o : %.c
tells make to build any object file somename.o from a source file somename.c.
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
It defines a rule that makes any file x.o from x.c.
This rule uses the automatic variables $< and $@ to substitute the names of the
first dependency and the target each time the rule is applied. The variables
$(CC), $(CFLAGS), and $(CPPFLAGS)
18. Excercise
Examine the example Makefile 3 & Makefile 4 in
1-18
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
20. Excercise
Examine the example Makefile 5 in
1-20
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
21. GNU Automake
The primary goal of Automake is to generate ‘Makefile’ in
compliant with the GNU Makefile Standards.
A secondary goal for Automake is that it work well with
other free software, and, specifically, GNU tools.
Automake helps the maintainer with five large tasks, and
countless minor ones.The basic functional areas are:
• Build
• Check
• Clean
• Install and uninstall
• Distribution
1-21
22. Building configure.in (or configure.ac)
The configure script ‘configure.in’ is responsible for
getting ready to build the software on your specific
system. It makes sure all of the dependencies for the rest
of the build and install process are available, and finds out
whatever it needs to know to use those dependencies.
A configure script ‘configure.in’ examines your system,
and uses the information it finds to convert
a Makefile.in template into a Makefile
To run the configure script
1-22
./configure
23. Building configure.in (or configure.ac)
1-23
AC_INIT (package, version, bug-report-address)
AC_OUTPUT([file...[,extra_cmds[,init_cmds]]])
Invoke before any test
Invoke after any test
unique_file_in_source_dir is a file present in the source code directory. The call to
AC_INIT creates shell code in the generated configure script that looks for
unique_file_in_source_dir to make sure that it is in the correct directory.
AC_OUTPUT creates the output files, such as Makefiles and other (optional) output
files
file is a space separated list of output files.
Configure.in
24. Structuring the file Configure.ac
1-24
AC_INIT
Tests for programs
Tests for libraries
Tests for header files
Tests for typedefs
Tests for structures
Tests for compiler behavior
Tests for library functions
Tests for system services
AC_OUTPUT
Configure.in
32. Using the autoconf
This program builds an executable shell script named
configure (from configure.in) that, when executed,
automatically examines and tailors a client’s build from
source according to software resources, or dependencies
(such as programming tools, libraries, and associated
utilities) that are installed on the target host (your Linux
system).
1-32
33. Example
1-33
#include <stdio.h>
int
main(int argc, char* argv[])
{
printf("Hello worldn");
return 0;
}
AC_INIT([helloworld], [0.1], [george@thoughtbot.com])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = helloworld
helloworld_SOURCES = main.c
Helloworld.c Configure.in
Makefile.am
aclocal #generate m4 env
autoconf #generate configure
automake –add-missing
configure
Makefile.in
./configure # Generate Makefile from Makefile.in
make # Use Makefile to build the program
make install # Use Makefile to install the program
34. Graphical DevelopmentTools
Ubuntu has a number of graphical prototyping and
development environments available
integrated development environment (IDE)
• Eclipse
• NetBeans
• Visual Studio Code
• Oracle JDeveloper
software development kit (SDK)
• Android development SDK
the KDevelop Client (for Developing in KDE)
The Glade Client (for Developing in GNOME)
1-34
35. Exercise
Download and install Eclipse IDE for C/C++ (or Java, PHP, etc.)
Check for Java installed: java –version
• Sudo apt install default-jre
Check OS type (64/32bit): uname -a
Download Eclipse C/C++ tarball file from
https://www.eclipse.org/downloads/eclipse-packages/
Extract and install
• tar –xf <tarball file.gz>
Run Eclipse: ./eclipse
Set PATH to run from $HOME directory
• PATH = $PATH:$HOME/<install directory>
1-35
Note: to permanently set PATH env, edit file $HOME/.profile
37. Using Java on Linux
Most Java development occurs in an IDE
Eclipse (www.eclipse.org)
NetBeans (www.netbeans.org)
1-37
38. Using JavaScript
To use JavaScript on Ubuntu, you write programs in your
favorite text editor. Nothing special is needed.
Put the script somewhere and open it with your web
browser.
Information is often passed using JavaScript Object
Notation, or JSON
JavaScript has spawned tons of extensions and
development kits, such as Node.js and JSP.
1-38
39. Using JavaScript
Node.js
Node.js is a popular JavaScript framework used for developing
server side applications.
1-39
sudo apt-get install nodejs
sudo apt-get install npm
sudo ln –s /usr/bin/nodejs /usr/bin/node
Console.log(“This is Ubuntu Node.js”)
~$ node hello.js Hello.js
40. Using Python
Most versions of Linux and UNIX, including macOS, come
with Python preinstalled
1-40
matthew@seymour:~$ python
Python 3.6.4 (default, Dec27 2017, 13:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information