1 / 25

Recitation Week 2

Recitation Week 2. Object Oriented Programming COP3330 / CGS5409. Today’s Recitation. Assignment Submission Overview Compiling with g++ Using Makefiles Misc. Review. Assignment Submission. Programs submitted through course web page http://www.cs.fsu.edu/~myers/cop3330

rrehm
Download Presentation

Recitation Week 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Recitation Week 2 Object Oriented Programming COP3330 / CGS5409

  2. Today’s Recitation • Assignment Submission Overview • Compiling with g++ • Using Makefiles • Misc. Review

  3. Assignment Submission • Programs submitted through course web page • http://www.cs.fsu.edu/~myers/cop3330 • Link: “Click me, if you dare…”

  4. Assignment Submission cont. • Submit source files only! • Only .cpp and .h files • DO NOT INCLUDE BINARIES! • If more than one file, upload each individually • Use FSU SN • Social Security number will not work • Require additional submission passwords • NOT THE SAME AS FSU/CS PASSWORDS!

  5. Assignment Submission cont. • Feedback from submission: • (1) a directory listing of files submitted for that assignment so far • (2) a copy of the file just submitted • Do not e-mail asking for confirmation! • Verify submission with above methods

  6. Misc. Submission Notes • The FSU SN is typed with dashes (i.e. AB3-45-6789, not AB3456789) • Passwords are all 8 characters long • The passwords do not contain any instances of the numeric digits 0 or 1 • Hang on to this password, it will be needed all semester!

  7. Misc. Submission Notes • Make sure to follow all submission instructions carefully • Homework submitted by e-mail to the instructor or me will NOT BE GRADED! • Can re-submit an updated file that was previously submitted • Will overwrite previous attempt

  8. Misc. Submission Notes • One late day submission is allowed (with a letter grade deduction) on assignments • After that time, course web site WILL NOT accept submissions • MAKE SURE TO SUBMIT BY THIS TIME

  9. Assignment Submission Test • Assignment Submission Practice • Option on the submission page called "Assignment 0“ • Will not be graded • http://www.cs.fsu.edu/~myers/cop3330

  10. Compiling C / C++ programs with gcc & g++ • The base command for the Gnu C compiler is "gcc" • The base command for the Gnu C++ compiler is "g++"

  11. Single File Programs • To compile a program that is in a single file, the easiest compilation uses the command format: g++ <filename> • Where the filename ends with ".cpp“ • Example: g++ prog1.cpp

  12. Multiple File Programs • To invoke the Compile stage, which translates source code (.cppfiles) into object code (.o files), use the -c flag. Format: g++ -c <filename> • To name a target (something other than the default filename, use the -o flag. Format: g++ -o <target_name> <remainder of command>

  13. Multiple File Examples • g++ -o yadda.o -c fraction.cpp • This command invokes just the compile stage on fraction.cpp, but names the object code file "yadda.o" (instead of the default "fraction.o"). • g++ -o bob.exe circle.omain.o • This command links the two object code files ("circle.o" and "main.o") into an executable, called "bob.exe" (instead of the default "a.out"). • g++ -o myProgram thing.cpp main.cpp • This command compiles and links (since -c not used) the code files "thing.cpp" and "main.cpp" together into the executable program called "myProgram".

  14. Reminders • Source code is just text! • For the purposes of assignments, ANY text editor can be used to • Practice with at least one Unix text editor create code files • For unix beginners, "pico" is recommended, due to easy learning curve. • Emacs, Vim, MUCH more powerful

  15. CS Account login • Understand how to log into both CS machines: • linprog.cs.fsu.edu • program.cs.fsu.edu • Use SSH (Secure SHell) client to login • Files created on a windows machine can be FTP-ed to CS accounts with the SFTP feature built into the SSH software

  16. SSH / SCP • Usage: sftp[username@]hostname • get filename - retrieve remote file • put filename - upload local file • Standard Unix commands: • cd, ls, pwd, chmod, rename, rm, mkdir, rmdir, help, quit • Alternatively, GUI File Managers • WinSCP- Free Windows client with SFTP capability • FileZilla- Open source cross-platform GUI client

  17. Makefiles • Unix system has what is called a ‘make’ utility • Configuration file to assist with compilation • Simple text file, should be named either ‘makefile’ or ‘Makefile’

  18. Makefiles • Idea of the ‘target’ • What is able to be ‘made’? • Dependency list • What needs to be re-made each time? • Command list, and formatting • i.e. it must be preceded by a single ‘tab’ character • Extra targets, like ‘clean’, for cleanup • target that lists a cleanup command (like the remove ‘rm’ command) • More than one target • placing a target like ‘all’ at the top, and listing the executables made by the file as the dependency list

  19. Sample Makefile # This is a comment line # Sample makefile for fraction class frac: main.ofrac.o g++ -o fracmain.ofrac.o main.o: main.cpp frac.h g++ -c main.cpp frac.o: frac.cpp frac.h g++ -c frac.cpp clean: rm*.o frac

  20. Sample Makefile frac: main.ofrac.o g++ -o fracmain.ofrac.o • Specifies ‘frac’ as the target • Depends on main.o and frac.o • If either of these files changed since the last build, then ‘frac’ must be rebuilt • Links two object code files together into a target executable called ‘frac’

  21. Sample Makefile main.o: main.cpp frac.h g++ -c main.cpp • Specifies how to built the target ‘main.o’ • Depends on main.cpp and frac.h • If either file changes, main.o must be rebuilt • Uses normal g++ commands for the compile stage

  22. Sample Makefile • Any section can be invoked specifically with the command: make <target_name> • For instance, to build only the ‘frac.o’ target, use: make frac.o

  23. Sample Makefile clean: rm *.o frac • The target name is ‘clean’ • Executes the remove command (‘rm’) • Removes the object code file(s) and the executable(s) from the current directory

  24. Additional Review Materials • http://www.cs.fsu.edu/~myers/c++/notes/functions2.html • Function overloading and default values on parameters • http://www.cs.fsu.edu/~myers/c++/notes/references.html • Reference variables, and more specifically, pass-by-reference • http://www.cs.fsu.edu/~myers/c++/notes/basics1.html • From this basics page, primarily the intro to C++ console I/O, with iostream library and usage of cout/cin • http://www.cs.fsu.edu/~myers/c++/notes/formatting.html • C++ formatting features for output streams, including stream manipulators and ios flags. • http://www.cs.fsu.edu/~myers/c++/notes/fileio.html • File I/O in C++ (using fstream library)

  25. Questions?

More Related