Top Banner
 If you already have the Cygwin gcc and g++ compilers, GNU make, and gdb debu gger installed
223

If You Already Have the Cyg and g

Apr 14, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 1/223

 

If 

you alreadyhave the

Cygwin gccand g++

compilers,GNU make,and gdb debu

gger installed

Page 2: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 2/223

on your Windows

system andyour path is

set upcorrectly to

find them,make sure

Page 3: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 3/223

that you havethe correct

versions.To check the

versions of your Cygwin

compilersand tools: 

Page 4: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 4/223

1. Check theversion of 

Cygwinenvironment

by typing thefollowing

commandsat a

Page 5: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 5/223

Windowscommand

prompt:2. 

3.  C:\>cygcheck

-c cygwin

Page 6: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 6/223

4. Check theversions of 

the Cygwingcc and g++

compilers, make,

and gdb by

typing the

Page 7: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 7/223

followingcommands

at aWindows

commandprompt:

5. 

Page 8: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 8/223

6.  C:\>gcc --

version7.  C:\>

g++ --version

Page 9: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 9/223

8.  C:\>make --

version9.  C:\>

gdb --version

If you havethe correct

Page 11: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 11/223

Page 12: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 12/223

compilers,  m ake,

and gdb debugger 

from cygwin.com: 1. Refer to

the Cygwin

Page 13: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 13/223

User'sGuide for 

completeinformation

aboutinstalling

and usingCygwin.

Page 14: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 14/223

Page 15: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 15/223

the leftnavigation

bar, or byclicking this

direct setup.exe link.

3. Run

the setup.

Page 16: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 16/223

exe program. Accept

the defaultsuntil you

reach theSelect Your 

InternetConnection

Page 17: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 17/223

page. Selectthe option

on this pagethat is best

for you.Click Next.

4. On theChoose

Page 18: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 18/223

DownloadSite page,

choose adownload

site youthink might

be relatively

Page 19: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 19/223

Page 20: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 20/223

download.Click the +

next toDevel to

expand thedevelopment

toolscategory.

Page 21: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 21/223

You maywant to

resize thewindow so

you can seemore of it at

one time.

Page 22: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 22/223

6. Selecteach

package youwant to

download byclicking the

Skip labelnext to it,

Page 23: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 23/223

whichreveals the

versionnumber of 

the packageto download.

 At a

Page 24: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 24/223

minimum,select 

gcc-core: Ccompiler 

  gcc-g++:C++compiler 

Page 25: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 25/223

 

gdb: TheGNU

Debugger   make: the

GNU versionof the 'make'

utility

Page 26: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 26/223

Packagesthat are

required bythe

packagesyou select

areautomaticall

Page 27: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 27/223

y selectedas well.

7. Click Nextto connect to

thedownload

site anddownload

Page 28: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 28/223

thepackages

youselected,

and clickFinish when

the

Page 29: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 29/223

installation iscomplete.

8. Now addthe Cygwin

compiler directory to

your path toenable

Page 30: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 30/223

NetBeansIDE to find

the toolscollection:

0. Open theControlPanel:

- On

Page 31: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 31/223

Page 32: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 32/223

System.- On

Windows 7,type var in

the Startmenu's

search boxto quickly

Page 33: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 33/223

find a linkto Edit the

systemenvironmen

t variables.1. Select

the Advanced

Page 34: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 34/223

tab andclick

Environment

Variables.2. In the

SystemVariables

Page 35: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 35/223

panel of theEnvironme

ntVariables

dialog,select

the Path v

Page 36: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 36/223

Page 37: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 37/223

Page 38: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 38/223

y  is C:\cygwin.

Directorynames

must beseparatedwith a

semicolon.

Page 39: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 39/223

Your editedpath should

looksomething

like %SystemRoot%\

system32;%System

Page 40: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 40/223

Root%;C:

\Program

Files\QuickTime\

QTSystem;C:\cygw

in\bin 

Page 41: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 41/223

4. Click OKin the

Environment

Variablesdialog and

the System

Page 43: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 43/223

installedcorrectly for 

theNetBeans

IDE.MinGW

Compilersand Tools

Page 44: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 44/223

NetBeansIDE 7.3 was

tested withMinimalist

GNU for Windows

(MinGW) andthe Minimal

Page 45: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 45/223

System(MSYS) Unix-

likeenvironment.

Versionstested and

installationinstructions

Page 46: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 46/223

are shownbelow.

Note. If youwant to use

Qt withWindows,

see thearticle Workin

Page 47: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 47/223

g with Qt Applications f 

or instructions

for installingMinGW and

Qt software.Sof Ve Descr 

Page 48: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 48/223

Page 49: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 49/223

c  6.2 compiler 

g+

4.

6.2

MinGW

C++compil

er gd

7. MinG

Page 50: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 50/223

b  4 WGNU

debugger 

ma

ke 3.81

MSYS make 

utility

Note

Page 51: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 51/223

thatMinG

Wmake

is notsuppo

rted

Page 52: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 52/223

Page 53: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 53/223

from mingw.org: 

1. Log in toWindows

using anaccount with

computer 

Page 54: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 54/223

administrator privileges.

2. Downloadthe MinGW

installer from http://s

ourceforge.n

Page 55: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 55/223

et/projects/mingw.

3. Run theMinGW

installer,which

should havea file name

Page 56: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 56/223

similar to mingw-

get-inst-20120426.

exe.4. Accept thedefault C:\M

inGW as the

Page 57: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 57/223

destinationfolder if 

possible tominimize

any potentialdifficulty with

using thecompilers

Page 58: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 58/223

from another location.

5. In theMinGW

installer select the

following

Page 59: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 59/223

Page 60: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 60/223

Fortran programs)  

MSYS BasicSystem

  MinGWDeveloper Toolkit

Page 61: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 61/223

6. ClickInstall and

wait a fewminutes

while theinstaller 

programdownloads

Page 62: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 62/223

thecomponents

youselected.

7. ClickFinish when

thepackages

Page 63: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 63/223

are finisheddownloading

.You must add

the paths tothe the

binaries for MinGW and

Page 64: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 64/223

MSYS toolsto your 

PATH. If youinstalled to

the defaultlocation the

pathsare C:\MinG

Page 65: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 65/223

W\bin andC:\MinGW\MSY

S\1.0\bin.To edit your 

PATHenvironmentvariable in

Windows: 

Page 66: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 66/223

1. Open theEnvironment

Variableswindow:  On WindowsXP and

Windows2000: Right-

Page 67: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 67/223

click MyComputer >

Properties > Advanced

tab >Environment

Variablesbutton.

Page 68: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 68/223

 

On WindowsVista and

Windows 7:Right-click

MyComputer >

Properties > Advanced

Page 69: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 69/223

SystemSettings link

>Environment

Variablesbutton.

2. In theEnvironment

Page 70: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 70/223

Page 71: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 71/223

section andclick Edit.

3. At the endof the path,

insert asemi-colon

and add thepaths to the

Page 72: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 72/223

executablesfor MinGW

and MSYS.Use semi-

colonsbetween the

paths anddo not use

Page 73: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 73/223

any spaces.Be careful

not toremove

anythingalready on

your PATHor your 

Page 74: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 74/223

computer might not

workcorrectly.

When youare finished,

your pathshould look

Page 75: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 75/223

similar to thefollowing:

%SystemRo

ot%\system32;%Syst

emRoot%;%SystemRoo

Page 76: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 76/223

t%\System

32\Wbem;

%SYSTEMROOT%\Syste

m32\WindowsPowerSh

ell\v1.0;C:\MinGW\

Page 77: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 77/223

bin;C:\Mi

nGW\MSYS\

1.0\bin4. Click OK

in theEnvironment

Variableswindow.

Page 79: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 79/223

the NetBeansIDE.

MicrosoftWindows

TheNetBeans

C/C++module has

Page 80: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 80/223

been testedwith

compilersfrom Cygwin

and MinGW.If you install

both Cygwinand MinGW,

Page 81: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 81/223

be careful tokeep their 

installationlocations

completelyseparate and

do not mixtools from

Page 82: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 82/223

Page 83: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 83/223

Windows, youmust use

MinGW. Seethe

article Working with Qt

 Applications f or instructions

Page 84: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 84/223

Page 85: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 85/223

and Tools 

Cygwin

Compilersand Tools

TheNetBeans

C/C++module has

Page 86: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 86/223

been testedwith the

followingcompilers and

toolsfrom Cygwin.

com.Soft Ve Des

Page 87: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 87/223

wareor 

Resource

rsion

Test

ed

cription

cygw

in1.dll 

1.7

.7,1.7

Cyg

winLinu

Page 88: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 88/223

Page 89: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 89/223

s

gcc  4.3

.4

Cyg

winC

compiler 

g++  4.3

.4

Cyg

win

Page 90: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 90/223

C++com

piler 

gdb  6.8

Cyg

winGN

Udeb

Page 91: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 91/223

ugger 

make 3.81

Cygwin

make

utility

Page 92: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 92/223

 

If you alreadyhave the

Cygwin gccand g++

compilers,GNU make,

Page 93: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 93/223

and gdb debugger installed

on your Windows

system andyour path is

set upcorrectly to

Page 94: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 94/223

Page 95: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 95/223

compilersand tools: 

1. Check theversion of 

Cygwinenvironment

by typing thefollowing

Page 96: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 96/223

commandsat a

Windowscommand

prompt:2. 

Page 97: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 97/223

3.  C:\>cygcheck

-c cygwin4. Check the

versions of the Cygwin

gcc and g++compilers, m

Page 98: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 98/223

ake,and gdb by

typing thefollowing

commandsat aWindows

Page 99: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 99/223

Page 100: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 100/223

7.  C:\>g++ --

version8.  C:\>

make --version

Page 101: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 101/223

9.  C:\>gdb --

versionIf you have

the correctversions, then

no further setup is

Page 102: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 102/223

Page 103: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 103/223

the NetBeansIDE.

To install theGNU gcc

and g++compilers,  m 

ake,

and gdb deb

Page 105: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 105/223

informationabout

installingand using

Cygwin.2. Download

theCygwin set

Page 106: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 106/223

up.exe program by

clickingInstall

Cygwin inthe left

navigationbar, or by

Page 107: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 107/223

clicking thisdirect setup

.exe link.3. Run

the setup.

exe program. Accept

the defaults

Page 108: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 108/223

until youreach the

Select Your Internet

Connectionpage. Select

the optionon this page

Page 109: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 109/223

that is bestfor you.

Click Next.4. On the

ChooseDownload

Site page,choose a

Page 110: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 110/223

downloadsite you

think mightbe relatively

close to you.Click Next.

5. On theSelect

Page 111: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 111/223

Packagespage you

select thepackages to

download.Click the +

next toDevel to

Page 112: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 112/223

expand thedevelopment

toolscategory.

You maywant to

resize thewindow so

Page 113: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 113/223

you can seemore of it at

one time.6. Select

eachpackage you

want todownload by

Page 114: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 114/223

clicking theSkip label

next to it,which

reveals theversion

number of the package

Page 115: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 115/223

to download. At a

minimum,select  gcc-core: Ccompiler 

Page 116: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 116/223

 

gcc-g++:C++

compiler   gdb: The

GNUDebugger 

  make: the

GNU version

Page 117: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 117/223

of the 'make'utility

Packagesthat are

required bythe

packagesyou select

Page 118: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 118/223

areautomaticall

y selectedas well.

7. Click Nextto connect to

thedownload

Page 119: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 119/223

site anddownload

thepackages

youselected,

and clickFinish when

Page 120: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 120/223

theinstallation is

complete.8. Now add

the Cygwincompiler 

directory toyour path to

Page 121: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 121/223

enableNetBeans

IDE to findthe tools

collection:0. Open theControl

Panel:

Page 122: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 122/223

- OnWindows

XP selectStart >

Settings >Control

Panel anddouble-

Page 123: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 123/223

clickSystem.

- OnWindows 7,

type var inthe Start

menu'ssearch box

Page 124: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 124/223

to quicklyfind a link

to Edit thesystem

environment variables.

1. Selectthe

Page 125: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 125/223

 Advancedtab and

clickEnvironme

ntVariables.

2. In theSystem

Page 126: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 126/223

Variablespanel of the

Environment

Variablesdialog,

selectthe Path v

Page 127: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 127/223

ariable andclick Edit.

3. Add thepath to

the cygwin-

director 

y \bin dire

Page 128: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 128/223

ctory tothe Path v

ariable, andclick OK.

Bydefault, cy gwin-

director 

Page 129: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 129/223

y  is C:\cygwin.

Directorynames

must beseparatedwith a

semicolon.

Page 130: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 130/223

Your editedpath should

looksomething

like %SystemRoot%\

system32;%System

Page 131: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 131/223

Page 132: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 132/223

4. Click OKin the

Environment

Variablesdialog and

the System

Page 134: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 134/223

installedcorrectly for 

theNetBeans

IDE.MinGW

Compilersand Tools

Page 135: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 135/223

Page 136: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 136/223

System(MSYS) Unix-

likeenvironment.

Versionstested and

installationinstructions

Page 137: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 137/223

are shownbelow.

Note. If youwant to use

Qt withWindows,

see thearticle Workin

Page 138: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 138/223

g with Qt Applications f 

or instructions

for installingMinGW and

Qt software.Sof Ve Descr 

Page 139: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 139/223

tware

or Re

sourc

e

rsion

Test

ed

iption

gc 4. C

Page 140: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 140/223

c  6.2 compiler 

g+

4.

6.2

MinGW

C++compil

er gd

7. MinG

Page 141: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 141/223

b  4 WGNU

debugger 

ma

ke 3.81

MSYS make 

utility

Note

Page 142: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 142/223

thatMinG

Wmake

is notsuppo

rted

Page 143: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 143/223

 

To install theGNU

compilers,  m ake,

and gdb deb

ugger 

Page 144: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 144/223

from mingw.org: 

1. Log in toWindows

using anaccount with

computer 

Page 145: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 145/223

administrator privileges.

2. Downloadthe MinGW

installer from http://s

ourceforge.n

Page 146: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 146/223

et/projects/mingw.

3. Run theMinGW

installer,which

should havea file name

Page 147: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 147/223

similar to mingw-

get-inst-20120426.

exe.4. Accept thedefault C:\M

inGW as the

Page 148: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 148/223

destinationfolder if 

possible tominimize

any potentialdifficulty with

using thecompilers

Page 149: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 149/223

from another location.

5. In theMinGW

installer select the

following

Page 150: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 150/223

componentsto install: 

C  C++  Fortran (if you will beworking on

Page 151: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 151/223

Fortran programs)  

MSYS BasicSystem

  MinGWDeveloper Toolkit

Page 152: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 152/223

6. ClickInstall and

wait a fewminutes

while theinstaller 

programdownloads

Page 153: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 153/223

thecomponents

youselected.

7. ClickFinish when

thepackages

Page 154: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 154/223

are finisheddownloading

.You must add

the paths tothe the

binaries for MinGW and

Page 155: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 155/223

MSYS toolsto your 

PATH. If youinstalled to

the defaultlocation the

pathsare C:\MinG

Page 156: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 156/223

W\bin andC:\MinGW\MSY

S\1.0\bin.To edit your 

PATHenvironmentvariable in

Windows: 

Page 157: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 157/223

Page 158: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 158/223

Page 159: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 159/223

 

On WindowsVista and

Windows 7:Right-click

MyComputer >

Properties > Advanced

Page 160: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 160/223

SystemSettings link

>Environment

Variablesbutton.

2. In theEnvironment

Page 161: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 161/223

Variableswindow,

select thePath

variable inthe Systems

Variable

Page 162: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 162/223

section andclick Edit.

3. At the endof the path,

insert asemi-colon

and add thepaths to the

Page 163: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 163/223

executablesfor MinGW

and MSYS.Use semi-

colonsbetween the

paths anddo not use

Page 164: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 164/223

any spaces.Be careful

not toremove

anythingalready on

your PATHor your 

Page 165: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 165/223

computer might not

workcorrectly.

When youare finished,

your pathshould look

Page 166: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 166/223

similar to thefollowing:

%SystemRo

ot%\system32;%Syst

emRoot%;%SystemRoo

Page 167: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 167/223

t%\System

32\Wbem;

%SYSTEMROOT%\Syste

m32\WindowsPowerSh

ell\v1.0;C:\MinGW\

Page 168: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 168/223

bin;C:\Mi

nGW\MSYS\

1.0\bin4. Click OK

in theEnvironment

Variableswindow.

Page 169: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 169/223

Page 170: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 170/223

the NetBeansIDE.

Code can beentirely

compiled;hence no

implementation source

Page 171: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 171/223

must bepublished

(distributingtemplate

librariesusually

requiresdistribution of 

Page 172: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 172/223

the sourcecode of the

templateimplementatio

ns).In contrast,

the followingcan be said

Page 173: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 173/223

about staticpolymorphism

in C++:Collections of 

built-in typesare easily

implemented.More

Page 174: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 174/223

generally, theinterface

commonalityneed not be

expressedthrough a

commonbase class.

Page 175: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 175/223

Generatedcode is

potentiallyfaster 

(because noindirection

throughpointers is

Page 176: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 176/223

needed a priori and

nonvirtualfunctions can

be inlinedmuch more

often).

Page 177: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 177/223

Concretetypes that

provide onlypartial

interfaces canstill be used if 

only that partends up

Page 178: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 178/223

beingexercised

by theapplication.

Staticpolymorphism

is oftenregarded as

Page 179: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 179/223

more typesafe than

dynamicpolymorphism

because allthe bindings

are

Page 180: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 180/223

checked atcompile time.

For example,there is little

danger of inserting an

object of the

Page 181: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 181/223

wrong type ina container 

instantiatedfrom a

template.However, in a

container expecting

Page 182: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 182/223

pointers to acommon

base class,there is a

possibilitythat these

pointersunintentionall

Page 183: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 183/223

y end uppointing to

completeobjects of 

differenttypes.

In practice,template

Page 184: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 184/223

instantiationscan also

cause somegrief when

differentsemantic

assumptionshide behind

Page 185: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 185/223

identical-looking

interfaces.For example,

surprises canoccur when a

template thatassumes an

Page 186: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 186/223

associativeoperator 

+ isinstantiated

for a type thatis not

associativewith respect

Page 187: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 187/223

to thatoperator. In

practice, thiskind of 

semanticmismatch

occurs lessoften with

Page 188: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 188/223

inheritance-based

hierarchies,presumably

because theinterface

specificationis

Page 189: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 189/223

moreexplicitly

specified.Combining

Both FormsOf course,

you couldcombine both

Page 190: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 190/223

forms of inheritance.

For example,you could

derivedifferent kinds

of geometric

Page 191: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 191/223

objects froma common

base class tobe able to

handleinhomogeneo

us collectionsof geometric

Page 192: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 192/223

objects.However,

you can stilluse templates

to write codefor a certain

kind of 

Page 193: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 193/223

geometricobject.

Thecombination

of inheritanceand

templates isfurther 

Page 194: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 194/223

described inChapter 16.

We will see(among other 

things)how the

virtuality of amember 

Page 195: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 195/223

function canbe

parameterized and how an

additionalamount of 

flexibility isafforded to

Page 196: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 196/223

staticpolymorphism

using theinheritance-

basedcuriously 

recurring template

Page 197: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 197/223

 pattern (or CRTP ).

Ru-BrdThis

documentwas created

by an

Page 198: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 198/223

Page 199: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 199/223

 78 CHAPTER

5: TheBuilding

Blocks of PHP. $_FILES

contains any

Page 200: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 200/223

variablesprovided to a

script throughfile uploads.

. $_SERVERcontains

informationsuch as

Page 201: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 201/223

headers, filepaths, and

scriptlocations.

. $_ENVcontains any

variablesprovided to a

Page 202: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 202/223

script as partof the server 

environment..

$_REQUESTcontains any

variablesprovided to a

Page 203: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 203/223

script viaGET, POST,

or COOKIE

inputmechanisms.

. $_SESSIONcontains any

Page 204: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 204/223

variables thatare currently

registered ina session.

Theexamples in

this book usesuperglobals

Page 205: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 205/223

in allapplicable

situations.Using

superglobalsis crucial in

creatingsecure

Page 206: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 206/223

applicationsbecause they

reduce thelikelihood

of user-injected input

to your scripts. By

Page 207: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 207/223

coding your scripts to

accept onlywhat you

want, in themanner 

defined byyou (from a

Page 208: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 208/223

form usingthe POST

method, or from a

session, for example),

you caneliminate

Page 209: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 209/223

some of theproblems

created byloosely

writtenscripts.

Data Types

Page 210: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 210/223

Differenttypes of data

take updifferent

amounts of memory and

may betreated

Page 211: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 211/223

differentlywhen they

aremanipulated

by a script.Some

programminglanguages

Page 212: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 212/223

thereforedemand that

theprogrammer 

declare inadvance

which type of data a

Page 213: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 213/223

variable willcontain. By

contrast, PHPis loosely 

typed ,meaning that

itautomatically

Page 214: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 214/223

determinesthe data type

at the timedata is

assigned toeach variable.

Thisautomatic

Page 215: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 215/223

typing is amixed

blessing. Onthe one hand,

it means thatvariables

can be usedflexibly—in

Page 216: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 216/223

one instance,a variable can

hold a stringand then later 

inthe script it

can hold aninteger or 

Page 217: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 217/223

some other data type. On

the other hand, this

flexibility canlead to

problems inlarger scripts

Page 218: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 218/223

if you arespecifically

expecting avariable to

hold one datatype when in

fact it holdssomething

Page 219: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 219/223

completelydifferent.

For example,suppose that

you havecreated code

to manipulate

Page 220: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 220/223

Page 221: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 221/223

and no arraystructure

is in place,errors will

occur whenthe code

attempts toperform

Page 222: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 222/223

array-specificoperations

on thevariable.

Table 5.1shows the

eight

Page 223: If You Already Have the Cyg and g

7/27/2019 If You Already Have the Cyg and g

http://slidepdf.com/reader/full/if-you-already-have-the-cyg-and-g 223/223

standard datatypes