System Programming - LAB 1 Programming Environments.

11
System Programming - LAB 1 Programming Environments

Transcript of System Programming - LAB 1 Programming Environments.

Page 1: System Programming - LAB 1 Programming Environments.

System Programming - LAB

1Programming Environments

Page 2: System Programming - LAB 1 Programming Environments.

General information

•Niccolo` Battezzati (

[email protected])

• web site: www.cad.polito.it/staff/battezzati

(teaching section)

• LABs schedule: WEDNESDAY 8:30 - 12:30

(LABINF)

Page 3: System Programming - LAB 1 Programming Environments.

Windows Programming

•MS Visual Studio 2005

•IDE for Windows programming in several languages (C/C++ for us) with support for Win-32 APIs

•Project-based programming

Page 4: System Programming - LAB 1 Programming Environments.

MS Visual Studio•To create a new project:

1.Win-32 API Console Application

2.C++ / Empty project

•Advices:

1.#include <windows.h> in each file that uses Win-32 APIs

2.#undef UNICODE before including <windows.h>

3.you can write both C and C++ code

Page 5: System Programming - LAB 1 Programming Environments.

Unix Programming

•Many different IDEs (Eclipse C/C++, Anjuta, Dev-C++, KDevelop)...

•... but also text-editor + makefiles

Page 6: System Programming - LAB 1 Programming Environments.

Makefiles

•Basics:

1.for each target there are compilation rules

2.rules are simple compilation commands

3.variables can be defined to improve generalization

4.use standard targets for good-practice programming

Page 7: System Programming - LAB 1 Programming Environments.

Makefiles - syntax

target: [dependencies]

rules

Any simple identifier

Compilation commands (gcc ...)(can use variables)

other targets that you need to execute first

YOU MUST INSERT a TAB SPACE!!!

Page 8: System Programming - LAB 1 Programming Environments.

Makefiles - example 1

SRC = main.c

compile:

gcc $(SRC) -o my_first_program

Page 9: System Programming - LAB 1 Programming Environments.

Makefiles - standard targets

•all: executes all the targets to perform compilation

•clean: removes temporary files (objects, etc.)

•distclean: removes also the executables

Page 10: System Programming - LAB 1 Programming Environments.

Makefiles - example 2

CC = gcc

SRC = main.c hello.c

EXE = hello

all: compile

compile:

$(CC) $(SRC) -Wall -o $(EXE)

clean:

rm -f *.o

distclean: clean

rm -f $(EXE)

variables definition

targets and rules

Page 11: System Programming - LAB 1 Programming Environments.

Access to shared locations

•On Windows:

1.Tools -> Map Network drive...

2.insert the share folder: \\cclix1\corsi\system-programming

•On Linux:

1./export/home/corsi/system-programming