Difference between revisions of "Programming:C++/Books/You Can Do It!: A Beginners Introduction to Computer Programming"

From WhyAskWhy.org Wiki
Jump to: navigation, search
m (Added note for header build steps; incomplete)
m (Updated the instructions for building the FGW Library using the version of MinGW bundled with Quincy 2005 and the source code from the publisher's site.)
Line 4: Line 4:
  
 
These are my notes from '''You Can Program in C++: A Programmer's Introduction''' <ref>ISBN 0470449586</ref>.
 
These are my notes from '''You Can Program in C++: A Programmer's Introduction''' <ref>ISBN 0470449586</ref>.
 
{{OldContentWarning}}
 
 
  
  
Line 14: Line 11:
  
  
== Getting by without the cd ==
+
== What if you don't have the cd? ==
  
If you're like me and checked this out from the library you probably did not get a copy of the cd. I visited the book's website <ref name="ycdi-book-website">[http://www.spellen.org/youcandoit/resources.htm Official website for this book]</ref> and downloaded the material from there. What didn't work for me was the link to [http://alstevens.com/quincy.html Quincy 2002].
+
Before purchasing a copy of the book & CD, I checked out a copy of the book from a library and did not have the CD. This was ok because at the time the author made the contents available from his website. <ref name="ycdi-book-website">[http://www.spellen.org/youcandoit/resources.htm Official website for this book]</ref> Unfortunately [http://www.whyaskwhy.org/blog/1176/ the author's website hasn't been operational for some time], however on the same note the publisher ''has'' newer content available for download. <ref name="ycdi-book-publisher-website">[http://www.wiley.com/legacy/wileychi/glassborowc++/material.html Publisher's book page]</ref>
  
Instead I visited Google and searched for it. I found that [http://www.codecutter.net/tools/quincy/ Quincy 2005] was available so I grabbed that. Thankfully Francis made the source for the graphics library used in the book available so it could be compiled for other versions of Mingw and even different tool-kits entirely.
+
At the time the author's website had a broken link to Quincy 2002, <ref name="quincy-2002-homepage">[http://alstevens.com/quincy.html Quincy 2002 homepage]</ref> but I was able to find Quincy 2005 <ref name="quincy-2005-homepage">[http://www.codecutter.net/tools/quincy/ Quincy 2005 homepage]</ref> which is a newer version of it. Thankfully it is still available for download for those that want to use it. Since Francis Glassborow made the source for the '''FGW Library''' (aka, "Playpen") available, we can compile it using newer versions of [[wikipedia:Mingw|MinGW]] or different compilers altogether. That's great because I like to use [[wikipedia:Netbeans|Netbeans]] and the current MinGW and plan on trying out Visual Studio as I'm going through the book.
  
{{InfoBox|info|Make sure to keep a copy of the <code>fgwlib.zip</code> file in a safe location in case you mess up any of the steps. This way you can unzip it and try again.}}
 
  
=== Building the fgw library for use with Quincy 2005 ===
+
=== Building the FGW library for use with Quincy 2005 ===
  
 
# Download Quincy 2005 v1.3 and install it.
 
# Download Quincy 2005 v1.3 and install it.
# Download all archives from the book's website <ref name="ycdi-book-website" />.
+
 
# Run <code>tutorial.exe</code>, extract to the folder where the tutorial already resides. It should create a folder called <code>tutorial</code>. For the rest of the directions I'll refer to this folder as the <code>tutorial</code> folder. I'll pretend it's located at <code>C:\Documents and Settings\deoren\Desktop\ycdi_files</code>
+
==== Prepping the folder structure ====
# Open the <code>tutorial</code> folder and look for a <code>fgw_headers</code> folder.
+
 
# Copy <code>C:\Program Files\quincy\mingw\lib\COMPLETE_THIS_PATH\libgdi32.a</code> and replace the <code>libgdi32.a</code> file within the <code>fgw_headers</code> folder.
+
# Download the <code>windows_tutorial.zip</code> file from the publisher's website for the book <ref name="ycdi-book-publisher-website" /> and extract to a temporary location.
# Extract <code>fgwlib.zip</code> and copy the updated <code>fgw_text.h</code> header file to <code>fgw_headers</code>.  Choose to overwrite the older file.
+
# Move all folders inside of <code>windows_tutorial</code> to <code>C:\tutorial</code>.
# Extract library_source.zip.  This should give you a folder called source4net.
+
# Move all files from the <code>C:\tutorial\source</code> directory to the <code>C:\tutorial\fgw_headers</code> directory, choosing to overwrite existing files.
 +
# Remove the <code>C:\tutorial\source</code> directory (should have nothing inside of it).
 +
# Remove the <code>C:\tutorial\libraries</code> directory as we're going to build a newer library file. Aside from the volume serial number, you should see the following:
 +
<pre>
 +
C:\tutorial>tree /F
 +
Folder PATH listing
 +
Volume serial number is 38B9-1B1A
 +
C:.
 +
├───chapter_1
 +
├───chapter_10
 +
├───chapter_11
 +
├───chapter_12
 +
├───chapter_13
 +
├───chapter_14
 +
├───chapter_15
 +
├───chapter_16
 +
├───chapter_17
 +
├───chapter_18
 +
├───chapter_2
 +
├───chapter_3
 +
├───chapter_4
 +
├───chapter_5
 +
├───chapter_6
 +
├───chapter_7
 +
├───chapter_8
 +
├───chapter_9
 +
└───fgw_headers
 +
        adler32.c
 +
        colournames.h
 +
        deflate.c
 +
        deflate.h
 +
        fgw_text.h
 +
        flood_fill.cpp
 +
        flood_fill.h
 +
        infblock.c
 +
        infblock.h
 +
        infcodes.c
 +
        infcodes.h
 +
        inffast.c
 +
        inffast.h
 +
        inffixed.h
 +
        inflate.c
 +
        inftrees.c
 +
        inftrees.h
 +
        infutil.c
 +
        infutil.h
 +
        keyboard.h
 +
        libfgw.a
 +
        line_drawing.cpp
 +
        line_drawing.h
 +
        makefile
 +
        minipng.cpp
 +
        minipng.h
 +
        mouse.h
 +
        playpen.cpp
 +
        playpen.h
 +
        point2d.cpp
 +
        point2d.h
 +
        point2dx.cpp
 +
        point2dx.h
 +
        shape.cpp
 +
        shape.h
 +
        trees.c
 +
        trees.h
 +
        winplaypen.gpj
 +
        zconf.h
 +
        zlib.h
 +
        zutil.c
 +
        zutil.h
 +
</pre>
 +
 
 +
==== Building the library ====
 +
 
 +
# Copy <code>C:\Program Files\quincy\MinGW\lib\libgdi32.a</code> to <code>C:\tutorial\fgw_headers\libgdi32.a</code> and replace any existing copy if it exists.
 
# Open a command prompt (Start->Run->cmd->Enter)
 
# Open a command prompt (Start->Run->cmd->Enter)
# <code>set path=%path%;C:\Program Files\quincy\mingw\bin</code>
+
# <code>set path=%path%;C:\Program Files\quincy\MinGW\bin</code>
# <code>cd C:\Documents and Settings\deoren\Desktop\ycdi_files\source4net</code>
+
# <code>cd C:\tutorial\fgw_headers</code>
 +
# <code>mkdir C:\tutorial\fgw_headers\Release</code>
 +
# <code>bash</code>
 
# <code>make</code>
 
# <code>make</code>
# Copy <code>libfgwz.a</code> to <code>fgw_headers</code>
+
# Every time the book tells you to add <code>fgwlib.a</code> to your project, reference <code>C:\tutorial\fgw_headers\libfgwlib.a</code> instead.
# Delete <code>fgwlib.a</code> so there is no confusion which file to add to your projects.
 
# Every time the book tells you to add <code>fgwlib.a</code> to your project, add your newly compiled <code>libfgwz.a</code> instead.
 
  
  
Line 54: Line 123:
 
# <code>cp Release/libfgwz.a .</code>
 
# <code>cp Release/libfgwz.a .</code>
 
# Configure IDE as appropriate
 
# Configure IDE as appropriate
 +
 +
 +
== References ==
  
 
<references />
 
<references />

Revision as of 18:08, 29 July 2012


These are my notes from You Can Program in C++: A Programmer's Introduction [1].


About the book

I'll attempt to give proper remarks for this book later, but suffice to say this book is well worth your time if you're learning C++. I like how Francis pays particular attention to the pitfalls of the language. He teaches you to always check for failing function calls (something a lot of "beginner books" fail to do) and teaches you how to use strings and vectors from the beginning in place of arrays.


What if you don't have the cd?

Before purchasing a copy of the book & CD, I checked out a copy of the book from a library and did not have the CD. This was ok because at the time the author made the contents available from his website. [2] Unfortunately the author's website hasn't been operational for some time, however on the same note the publisher has newer content available for download. [3]

At the time the author's website had a broken link to Quincy 2002, [4] but I was able to find Quincy 2005 [5] which is a newer version of it. Thankfully it is still available for download for those that want to use it. Since Francis Glassborow made the source for the FGW Library (aka, "Playpen") available, we can compile it using newer versions of MinGW or different compilers altogether. That's great because I like to use Netbeans and the current MinGW and plan on trying out Visual Studio as I'm going through the book.


Building the FGW library for use with Quincy 2005

  1. Download Quincy 2005 v1.3 and install it.

Prepping the folder structure

  1. Download the windows_tutorial.zip file from the publisher's website for the book [3] and extract to a temporary location.
  2. Move all folders inside of windows_tutorial to C:\tutorial.
  3. Move all files from the C:\tutorial\source directory to the C:\tutorial\fgw_headers directory, choosing to overwrite existing files.
  4. Remove the C:\tutorial\source directory (should have nothing inside of it).
  5. Remove the C:\tutorial\libraries directory as we're going to build a newer library file. Aside from the volume serial number, you should see the following:
C:\tutorial>tree /F
Folder PATH listing
Volume serial number is 38B9-1B1A
C:.
├───chapter_1
├───chapter_10
├───chapter_11
├───chapter_12
├───chapter_13
├───chapter_14
├───chapter_15
├───chapter_16
├───chapter_17
├───chapter_18
├───chapter_2
├───chapter_3
├───chapter_4
├───chapter_5
├───chapter_6
├───chapter_7
├───chapter_8
├───chapter_9
└───fgw_headers
        adler32.c
        colournames.h
        deflate.c
        deflate.h
        fgw_text.h
        flood_fill.cpp
        flood_fill.h
        infblock.c
        infblock.h
        infcodes.c
        infcodes.h
        inffast.c
        inffast.h
        inffixed.h
        inflate.c
        inftrees.c
        inftrees.h
        infutil.c
        infutil.h
        keyboard.h
        libfgw.a
        line_drawing.cpp
        line_drawing.h
        makefile
        minipng.cpp
        minipng.h
        mouse.h
        playpen.cpp
        playpen.h
        point2d.cpp
        point2d.h
        point2dx.cpp
        point2dx.h
        shape.cpp
        shape.h
        trees.c
        trees.h
        winplaypen.gpj
        zconf.h
        zlib.h
        zutil.c
        zutil.h

Building the library

  1. Copy C:\Program Files\quincy\MinGW\lib\libgdi32.a to C:\tutorial\fgw_headers\libgdi32.a and replace any existing copy if it exists.
  2. Open a command prompt (Start->Run->cmd->Enter)
  3. set path=%path%;C:\Program Files\quincy\MinGW\bin
  4. cd C:\tutorial\fgw_headers
  5. mkdir C:\tutorial\fgw_headers\Release
  6. bash
  7. make
  8. Every time the book tells you to add fgwlib.a to your project, reference C:\tutorial\fgw_headers\libfgwlib.a instead.


Building the fgw library using the latest MinGW and MSYS tools

These steps assume you've previously built the library and already have the tutorial.exe contents extracted and the library source files updated. I'll need to clean up these directions so they make better sense.


  1. Download and install the latest MinGW and MSYS tools
  2. Either permanently modify the PATH variable, or temporarily modify it with set PATH=%PATH%;C:\MinGW\bin;C:\MinGW\msys\1.0\bin
  3. cd \tutorial\fgw_headers
  4. rmdir /s /q Release
  5. mkdir Release
  6. bash
  7. make clean
  8. make
  9. cp Release/libfgwz.a .
  10. Configure IDE as appropriate


References

  1. ISBN 0470449586
  2. Official website for this book
  3. 3.0 3.1 Publisher's book page
  4. Quincy 2002 homepage
  5. Quincy 2005 homepage