Linux/g++: Maze solving in CSE326. Linux machines at U. W. Machine Names: Ceylon, Sumatra, Fiji, Tahiti

Slides:



Advertisements
Similar presentations
Technotronics GCECT '091 Decode C This is a C Programming event, where you will be given problems to solve using C only. You will be given a Linux system.
Advertisements

Coding and Debugging. Requirements and Specification Recall the four steps of problem solving: Orient, Plan, Execute, Test Before you start the implementation.
Utilizing the GDB debugger to analyze programs Background and application.
Introduction to the gedit editor. gedit: the Gnome editor Gnome: Gnome is a freely available (i.e., no cost) desktop environment for the UNIX system The.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
PacNOG 6: Nadi, Fiji Using Commands in Linux Hervey Allen Network Startup Resource Center.
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 The CS-220 Development Environment.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Memory & Storage Architecture Seoul National University Computer Architecture “ Bomb Lab Hints” 2nd semester, 2014 Modified version : The original.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CSE 326: Your Computing Environment Steve Martin Aiman Erbad.
Gdb is the GNU debugger on our CS machines. gdb is most effective when it is debugging a program that has debugging symbols linked in to it. With gcc and.
Using the “CLI” Unix / Linux Preparation Course May 25 Djibouti.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Introduction to Shell Script Programming
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Copyright © 2009 Techtronics'09 by GCECT 1 Presents, De Code C De Code C is a C Programming competition, which challenges the participants to solve problems.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Main Memory Central Processor Unit Keyboard Input Device Secondary Memory Monitor Printer Output Devices.
August 7, 2003Serguei A. Mokhov, 1 gcc Tutorial COMP 444/5201 Revision 1.1 Date: January 25, 2004.
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
Old Chapter 10: Programming Tools A Developer’s Candy Store.
Carnegie Mellon Linux Boot Camp Jenna MacCarley, Peter Pearson, Shashank Goyal 9/19/2015.
Intro. To Unix commands For those who’ve never used Unix before Quick tutorial to let you move around your Unix Accounts No discussion of inner workings.
Using Commands Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
Next Unix Topics Tuesday, 2/11 & 18/2014. Change Password (by 2/14/14) ssh to account on – faclinux.cse.ohio-state.edu – stdlinux.cse.ohio-state.edu passwd.
Using Commands Unix / Linux Preparation Course May 6, 2012 Serrekunda, The Gambia.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
Unix and Samba By: IC Labs (Raj Kidambi). What is Unix?  Unix stands for UNiplexed Information and Computing System. (It was originally spelled "Unics.")
Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
Chapter Three The UNIX Editors.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Using the “CLI” Unix / Linux Preparation Course June 9, 2013 Lusaka, Zambia.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
More Unix Naomi Altman. Directories Directory = folder mkdir - makes a new directory rmdir - removes an empty directory cd mydirectory - moves you into.
Object Oriented Programming COP3330 / CGS5409.  Assignment Submission Overview  Compiling with g++  Using Makefiles  Misc. Review.
Lab 9 Department of Computer Science and Information Engineering National Taiwan University Lab9 - Debugging I 2014/11/4/ 28 1.
 Simple UNIX commands  I/O techniques in C++  Solutions to Lab#0 problems  Solutions to Lab#1 problems 1.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
1 CS101 Fall 2001 Lecture 1 In order to write a program, you must first telnet to your pegasus account and login either from a Rutgers computer in a lab,
 Prepared by: Eng. Maryam Adel Abdel-Hady
 Prepared by: Eng. Maryam Adel Abdel-Hady
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
1 Using an Integrated Development Environment. Integrated Development Environments An Integrated Development Environment, or IDE, permits you to edit,
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors Locate seg faults and bus errors Prepared by Dr. Spiegel.
Introduction to Unix – CS 21
Development Environment
Gnu Debugger (gdb) Debuggers are used to: Find semantic errors
CS1010: Intro Workshop.
Development Environment Basics
Guide To UNIX Using Linux Third Edition
Editor, Compiler, Linker, Debugger, Makefiles
gdb gdb is the GNU debugger on our CS machines.
Computer Architecture “Bomb Lab Hints”
Getting Started: Developing Code with Cloud9
TA: Maya Rodrig Our C++ guru: Nic Bone
Using emacs and G++ at U. W.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Appendix F C Programming Environment on UNIX Systems
Running a Java Program using Blue Jay.
Debugging.
Presentation transcript:

Linux/g++: Maze solving in CSE326

Linux machines at U. W. Machine Names: Ceylon, Sumatra, Fiji, Tahiti labs.htmlhttp:// labs.html Access –Use X-terminals in back of Sieg 329 (click on one of the linux machine names) –Use Windows machine, ask someone in lab for help

Make project directory More UNIX commands are at:

Look at supplied files d????????? means it’s a directory. Ignore RCS (not mentioned in project description)

Copy Files Oops, forgot this. Even TAs make mistakes

Interlude: ‘man’ Keys: q – exit man Page Up Page Down The command: apropos copy Finds all man pages that contain the word “copy” in their descriptions. Useful for finding out about a command.

Look at files in my dir

My files are read-only ‘w’ here means I can write to the files, but no-one else can

chmod (thanks to Nic Bone) > I'm having trouble understanding the man files. How would I change permission to > -rwxr--r-- > > What's the syntax? The easy-to-remember way to do this is to type: % chmod a+r file % chmod u+wx file % chmod go-wx file Meaning of the symbols: r: read w: write x: execute u: user g: group o: other a: all three (u, g, and o) +: add this permission -: remove this permission You can also set the permissions with one command using a numeric code of three numbers in the range 0-7. The first number corresponds to user permissions, the second to group permissions, and the third to other (or world) permissions. Read permission is +4, write permission is +2, and execute permission is +1. So to change permission to -rwxr--r--, we would type: % chmod 744 file Nic.

How to make runmaze (the program)

Test run./ is important. By default, Linux won’t search the current directory for a program. So you have to explicitly tell it (eventually, you can change your PATH environment variable) < means get the input from the file to the right (inputs/maze1.txt), instead of the keyboard. If you don’t put this in, runmaze will expect you to type the maze in on the keyboard – quite a hassle!

Run sample solution

Run runmaze with visualization What we type: Extra visualization window pops up (only implemented on Linux)

Edit runmaze.cpp – forgot & Darn, now we lost this shell until we close emacs

Edit runmaze.cpp Current line number

Emacs keys CTRL-X S (hold down control for both letters) –Save your work CTRL-X C –Exit emacs CTRL-G –Abort current command (if you accidentally typed something wrong) More: –(Quick intro) –(official documentation)

Simple change to runmaze.cpp Change

Re-make program

Run re-made version

Intro to make – project file dependencies

2 lines from Makefile runmaze : runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o g++ -o runmaze -g runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o -L/usr/X11R6/lib -lX11 runmaze (executable file) is dependant on a bunch of object files If runmaze doesn’t exist, or is out of date (relative to object files), here’s how to build it WARNING: this is a tab character. It has to be tab, and can’t be spaces. Those are the rules.

g++ linking command line g++ -o runmaze -g runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o -L/usr/X11R6/lib -lX11 -o runmaze –Call the output file ‘runmaze’ (instead of a.out, which is the default) -g –Include debugging information, so you can use a debugger -L/usr/X11R6/lib -lX11 –Include X-Windows libraries (for visualization part)

2 lines for runmaze.cpp (well, technically runmaze.o) runmaze.o : runmaze.cpp Maze.h SquareMaze.h MazeRunner.h RandomMazeRunner.h VisualizeSquareMazeRunner.h g++ -Wall -c -g runmaze.cpp The object file runmaze.o depends on runmaze.cpp + some.h files The infamous tab character strikes again! If runmaze.o doesn’t exist, or is out of date relative to the files past the colon ( : ), here’s how to build it with g++.

g++ compiling flags -c –Only compile, don’t link – we’ll let make decide when to link. -Wall –g++ will give us all of the Warnings it can think of. Maybe it’ll help us find a bug quickly. -g –Add debugging information. Is this the g as in –g? Who knows?

So you want to add a.h file Add it to every.o/.cpp that #includes it, directly or indirectly. runmaze.o : runmaze.cpp Maze.h SquareMaze.h MazeRunner.h RandomMazeRunner.h VisualizeSquareMazeRunner.h Fictitious.h g++ -Wall -c -g runmaze.cpp MazeRunner.o : MazeRunner.cpp Maze.h MazeRunner.h Fictitious.h g++ -Wall -c -g MazeRunner.cpp RandomMazeRunner.o : RandomMazeRunner.cpp Maze.h MazeRunner.h RandomMazeRunner.h g++ -Wall -c -g RandomMazeRunner.cpp But RandomMazeRunner.cpp doesn’t #include Fictitious.h (in our example)

Adding a.cpp file runmaze : runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o Bogus.o g++ -o runmaze -g runmaze.o MazeRunner.o RandomMazeRunner.o Maze.o SquareMaze.o VisualizeSquareMazeRunner.o GPKernel.o Bogus.o -L/usr/X11R6/lib -lX11 Bogus.o : Bogus.cpp Bogus.h Maze.h MazeRunner.h g++ -Wall -c -g Bogus.cpp Add.o file to dependencies of executable program Also, add.o file to list of files to link in (must do both) Tell make how to make Bogus.o

Debugging Zasha recommends: –add print statements (or cout<<) so you can see what your program is doing. –Make them check a global variable (doDebug), so you can turn them off & on (to turnin for grading) –Learn debugger later. Or –use gdb (see below) –use xxgdb (has dinky graphical user interface)

start it/set a couple of breakpoints break gdbSquareMaze::getStartMazeNode is the form for putting a breakpoint on a C++ class method.

Run program in gdb To see more commands, the help command is help or look at the extra information pointers near the beginning of these slides.

More info 326 Computing page (more info on these tools) – puting.htmlhttp:// puting.html GNU Info pages – Friendly people in lab / other students man command osmosis