Step 1
- look at the code
- open
trypoly.cpp
- create a Pentagon, call its
perimeter
method - Compile via
make
, execute via./trypoly
- you may have to add current directory to your LD_LIBRARY_PATH :
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:.
- create an Hexagon, call its
perimeter
method - recompile and check what happens
Step 2
- create an Hexagon, call its parent’s
perimeter
method - recompile and check again
- retry with virtual methods
- preprocess
Polygons.cpp
(g++ -E -o output
) - compile
Polygons.o
andtrypoly.o
(g++ -c -o output
) - use
nm
to check symbols in.o
files - look at the
Makefile
- try
make clean; make
- see linking stage using
g++ -v
- just add a
-v
in the Makefile command fortrypoly
- run
make clean; make
- look at the collect 2 line, from the end up to
-o trypoly
- just add a
- see library dependencies of
trypoly
andPolygons.so
withldd
- On OS X, use
otool -L
for a similar effect
- On OS X, use