Correct C++ tutorial part 5 "How to use libraries" available (Windows, mingw/msvc/std)

Discussion in 'C++' started by Alf P. Steinbach, Feb 8, 2005.

  1. The fifth part of my attempted Correct C++ tutorial is now available,
    although for now only in Word format (use free Open Office if no Word), and
    also, it's not yet been reviewed at all -- comments welcome!

    "How to use libraries"
    <url: http://home.no.net/dubjai/win32cpptut/w32cpptut_01_05.doc>

    General URL:

    <url: http://home.no.net/dubjai/win32cpptut/html/>

    which provides parts 1 and 2 as web-pages (HTML) in addition to the
    original Word documents of parts 1 through 5.

    This fifth part is very concrete, very tool-oriented, and is therefore
    possibly more difficult (it was far more difficult and time-consuming
    to write than the earlier parts), and I think therefore also has a higher
    chance of containing errors, sub-optimal ways of doing things, etc.

    Contents, part 5:
    1 [Background:] Classes, members & optional arguments.
    2 Use library-specified types.
    3 Find a library (or: find a set of libraries...).
    4 Use a make-tool to build a library (long).
    5 Use a Unix-like build environment for the GNU tools (long).
    6 Do the same things for a second library (it's easier now!).
    7 Create a library manually (the third time's the charm!).
    8 Fix invalid C++ source code (the "old iostream" problem).
    9 Use a library: create a picture programmatically.
    10 Use header file wrappers (introducing the C++ preprocessor).
    11 Use compiler response files.

    As before, the point of inviting comments is to _fix_ anything incorrect, or
    the presentation, or whatever; your input is valuable, and you can thereby
    help those who stumble across this tutorial and use it to learn C++.

    Thanks in advance,

    - Alf

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Feb 8, 2005
    #1
    1. Advertising

  2. Alf P. Steinbach wrote:
    > The fifth part of my attempted Correct C++ tutorial is now available,
    > although for now only in Word format (use free Open Office if no

    Word), and
    > also, it's not yet been reviewed at all -- comments welcome!
    >
    > "How to use libraries"
    > <url: http://home.no.net/dubjai/win32cpptut/w32cpptut_01_05.doc>
    >
    > General URL:
    >
    > <url: http://home.no.net/dubjai/win32cpptut/html/>
    >
    > which provides parts 1 and 2 as web-pages (HTML) in addition to the
    > original Word documents of parts 1 through 5.
    >
    > This fifth part is very concrete, very tool-oriented, and is

    therefore
    > possibly more difficult (it was far more difficult and time-consuming
    > to write than the earlier parts), and I think therefore also has a

    higher
    > chance of containing errors, sub-optimal ways of doing things, etc.


    Howdy Alf, this is very good, but don't you think you should dive into
    the bbasics of e.g. classes and other language semantics before going
    into creating libraries etc...?
    I would prefer if this was chapter 10 maybe instead of chapter 5...

    Thomas

    --
    www.frostinnovation.com THE Pocket PC Service System Provider
    Thomas Hansen, Feb 17, 2005
    #2
    1. Advertising

  3. * Thomas Hansen:
    >
    > Howdy Alf, this is very good, but don't you think you should dive into
    > the bbasics of e.g. classes and other language semantics before going
    > into creating libraries etc...?


    Well it's either that or use very platform-specific examples (e.g.
    Windows API metafiles) or only very very dull examples or, write some
    articially easy-to-use support libraries, perhaps with installer...

    I did write a simple XBM image generator (an XBM image file is pure text,
    actually C source code, which means std::cout is all the tool you need to
    generate an XBM image file), but black/white is boring and Internet
    Explorer 6.x doesn't seem to support the format, although reportedly
    almost all other browsers do. I know earlier versions supported XBM for
    internal web-page scripting. Perhaps IE 6 does still, haven't checked.

    But the main reason I decided to go "out on the net" to fetch a library
    was to _get real_, because it's the actual requirements of using real
    code that drives the learning curve (in my experience, that is): which
    features and tools and techniques need to be introduced and in what order.
    Generating a PNG picture is trivial in C# + .NET, a beginner's task. It
    shouldn't be that hard in C++, and it really isn't: it's just the tool
    usage to (once) install the necessary libraries that is a bit complex.


    > I would prefer if this was chapter 10 maybe instead of chapter 5...


    Heh. :)

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Feb 17, 2005
    #3
  4. (Alf P. Steinbach) wrote in message news:<>...
    > * Thomas Hansen:
    > >
    > > Howdy Alf, this is very good, but don't you think you should dive into
    > > the bbasics of e.g. classes and other language semantics before going
    > > into creating libraries etc...?

    >
    > Well it's either that or use very platform-specific examples (e.g.
    > Windows API metafiles) or only very very dull examples or, write some
    > articially easy-to-use support libraries, perhaps with installer...
    >

    Might initial reaction was that I can't think of any sort of audience
    that would have the patience to go through all the steps required to
    download 2 or 3 separate libraries, configure/produce makefiles to
    build them (even with a helping hand), and even modify the source to
    get it to compile, but would not know what a member function was, or
    even how to write a function (which you mention as the "next step" at
    the end).

    Having said that, I actually appreciate the fact that this tutorial
    doesn't try to make everything look super simple - it all-too-honestly
    recognises and addresses many of the typical complications that
    programmers have to face when developing applications of any level of
    sophistication. But Thomas is right, it's basically a chapter 10
    tutorial, not a chapter 5 one.

    Yes, it's unfortunate that there isn't a very very simple graphics
    format that could both be generated by the most basic of C++ programs
    and that most Windows users would be able to view without downloading
    additional software, but if you really are keen to get users to
    generate graphical images that soon, then I'd suggest having to
    download an XBM or PNM viewer for Windows is a loss less work than
    everything you're currently expecting of the poor novice programmer!
    Dylan Nicholson, Feb 18, 2005
    #4
  5. * Dylan Nicholson:
    > (Alf P. Steinbach) wrote in message news:<>...
    > > * Thomas Hansen:
    > > >
    > > > Howdy Alf, this is very good, but don't you think you should dive into
    > > > the bbasics of e.g. classes and other language semantics before going
    > > > into creating libraries etc...?

    > >
    > > Well it's either that or use very platform-specific examples (e.g.
    > > Windows API metafiles) or only very very dull examples or, write some
    > > articially easy-to-use support libraries, perhaps with installer...
    > >

    > Might initial reaction was that I can't think of any sort of audience
    > that would have the patience to go through all the steps required to
    > download 2 or 3 separate libraries, configure/produce makefiles to
    > build them (even with a helping hand), and even modify the source to
    > get it to compile, but would not know what a member function was, or
    > even how to write a function (which you mention as the "next step" at
    > the end).


    The description is incorrect: there's no "configure/produce makefiles".

    The makefiles are made by those who created the libraries.

    Also, why on Earth should a _patient_ person necessarily know about
    C++ member functions?


    > Having said that, I actually appreciate the fact that this tutorial
    > doesn't try to make everything look super simple - it all-too-honestly
    > recognises and addresses many of the typical complications that
    > programmers have to face when developing applications of any level of
    > sophistication.


    "all-too-honestly"?


    > But Thomas is right, it's basically a chapter 10
    > tutorial, not a chapter 5 one.


    There are no prerequisites apart from a little patience and "can do" attitude.

    People do not get more patient and "can do" as they learn more C++, they do
    not develop new personality traits (except for a slight tendency to mutter
    hexadecimal phrases), and knowing more C++ won't help in installing libraries.

    Hence there's no good reason to wait.

    Why should the reader be denied the tools to actually _do_ something?

    What is accomplished by waiting, like no sex before marriage?

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Feb 18, 2005
    #5
  6. Re: Correct C++ tutorial part 5 "How to use libraries" available(Windows, mingw/msvc/std)

    Alf P. Steinbach wrote:

    > The description is incorrect: there's no "configure/produce makefiles".
    >
    > The makefiles are made by those who created the libraries.
    >
    > Also, why on Earth should a _patient_ person necessarily know about
    > C++ member functions?



    I am a newcomer to Windows programming and do not use any makefiles. In
    fact I do not know what exactly they are. So I suppose makefiles is a
    system dependent thing, and I think a C++ tutorial should not be
    concerned with implementations but only with ISO C++.

    And BTW keep it as simple as possible.



    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
    Ioannis Vranos, Feb 18, 2005
    #6
  7. Alf P. Steinbach wrote:
    > * Thomas Hansen:
    > >
    > > Howdy Alf, this is very good, but don't you think you should dive

    into
    > > the bbasics of e.g. classes and other language semantics before

    going
    > > into creating libraries etc...?

    >
    > Well it's either that or use very platform-specific examples (e.g.
    > Windows API metafiles) or only very very dull examples or, write some
    > articially easy-to-use support libraries, perhaps with installer...


    Well, you could have progressed pretty far beyond branching by just
    doing things like this first:
    class Base
    {
    public:
    virtual void foo()
    {
    std::cout << "Base::foo()";
    }
    };

    class Derived : public Base
    {
    public:
    virtual void foo()
    {
    std::cout << "Derived::foo()";
    }
    };

    int main()
    {
    std::auto_ptr<Base> ptr( new Derived() );
    ptr->foo();
    return EXIT_SUCCESS;
    }

    ....
    Just my two cents...
    But I like to learn the language semantics before I learn how to use
    third part libraries/tools/etc...

    All though that chapter is pretty importent I think it's wise to first
    learn how to crawl, then to walk and then to think things like "why
    walk when I can drive"...
    ;)


    ..t
    Thomas Hansen, Feb 22, 2005
    #7
  8. Re: Correct C++ tutorial part 5 "How to use libraries" available (Windows, mingw/msvc/std)

    * Ioannis Vranos:
    > Alf P. Steinbach wrote:
    >
    > > The description is incorrect: there's no "configure/produce makefiles".
    > >
    > > The makefiles are made by those who created the libraries.
    > >
    > > Also, why on Earth should a _patient_ person necessarily know about
    > > C++ member functions?

    >
    >
    > I am a newcomer to Windows programming and do not use any makefiles. In
    > fact I do not know what exactly they are. So I suppose makefiles is a
    > system dependent thing,


    Makefiles originated, as far as I know, with the Unix system, but are
    now supported on all major platforms.

    A typical makefile specifies how to build something, by listing
    goals to be achieved (typically files to be produced), dependencies
    between goals (the make tool checks the modification times of files
    and infers from that and the dependencies which goals to pursue in
    which order to do the minimum necessary for the top-level goal), and the
    commands to be executed to achieve each goal.

    Makefiles, or some other build automation such as Ant or your
    favorite IDE's build command (which probably uses a generated makefile!)
    are necessary to create things that consist of more than one C++ source
    file, and/or to create things that are to be more-or-less _portable_,
    to automate the (re)build process.

    In medium or large projects makefiles can be preferred over IDE "projects"
    because they can work with almost any tools, and are independent of IDE.

    But in the same way as with C++ it's possible to write non-portable and
    tool-specific makefiles.


    > and I think a C++ tutorial should not be
    > concerned with implementations but only with ISO C++.


    Well, as I see it it's in the nature of a tutorial to be concerned with the
    in-practice, but that doesn't mean to teach some dialect of C++: I think
    you'll find that so far it's been only straight ISO C++.


    > And BTW keep it as simple as possible.


    I'm trying -- but no simpler... ;-)

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Feb 22, 2005
    #8
  9. * Thomas Hansen:
    >
    > .... you could have progressed pretty far beyond branching by just
    > doing things like this first:
    > class Base
    > {
    > public:
    > virtual void foo()
    > {
    > std::cout << "Base::foo()";
    > }
    > };
    >
    > class Derived : public Base
    > {
    > public:
    > virtual void foo()
    > {
    > std::cout << "Derived::foo()";
    > }
    > };
    >
    > int main()
    > {
    > std::auto_ptr<Base> ptr( new Derived() );
    > ptr->foo();
    > return EXIT_SUCCESS;
    > }
    >
    > ...
    > Just my two cents...
    > But I like to learn the language semantics before I learn how to use
    > third part libraries/tools/etc...
    >
    > All though that chapter is pretty importent I think it's wise to first
    > learn how to crawl, then to walk and then to think things like "why
    > walk when I can drive"...
    > ;)


    I agree with the premises but I think they support and imply the exact
    opposite conclusion... ;-)

    Namely, learn how to use things that are designed to be easy to use before
    learning to create them, which can be very difficult and can involve a really
    staggering amount of detail unrelated to the immediate goals. For example,
    learn how to drive a car before learning to design one. Would you rather
    start with learning how to modify the engine to support faster driving?

    There's an amount of trust involved, I think. The reader must trust that I
    know of what I'm talking about and the way I'm pointing out and leading the
    party onwards on. Explaining all the time that this will make sense later is
    in my view an exercise in futility, since that's exemplified again and again;
    but if the basic trust isn't there to begin with it might seem continually
    surprising (e.g., the personell manager in a large consulting firm once asked
    me right out whether I intentionally said and wrote things that only made
    sense -- i.e. to some other persons -- some time later down the road, and
    that's one price to pay for doing things right in the first place; to get a
    _consensus_ that something is right, when one isn't in a position of being a
    recognized authority, the issues must first be demonstrated and experienced
    personally by the involved persons, and that can have a huge cost).

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Feb 23, 2005
    #9
  10. (Alf P. Steinbach) wrote in message news:<>...
    > * Thomas Hansen:
    > >
    > > All though that chapter is pretty importent I think it's wise to first
    > > learn how to crawl, then to walk and then to think things like "why
    > > walk when I can drive"...
    > > ;)

    >
    > I agree with the premises but I think they support and imply the exact
    > opposite conclusion... ;-)
    >
    > Namely, learn how to use things that are designed to be easy to use before
    > learning to create them, which can be very difficult and can involve a really
    > staggering amount of detail unrelated to the immediate goals. For example,
    > learn how to drive a car before learning to design one. Would you rather
    > start with learning how to modify the engine to support faster driving?
    >

    Nifty analogy, but your current tutorial goes at great lengths to
    explain which shops sell cars, where to find them, how to purchase
    one, how to get it home, then all the various
    adjustments/customizations you might need to make to it before you can
    even start it. I wouldn't normally consider this part of "learning to
    drive".

    So ideally the user shouldn't need to worry about how the library gets
    on to their machine, and getting it ready for use should be a
    no-brainer. Unfortunately this isn't really possible unless you
    severely limit the number of possible platforms - but it seems you
    have already done this anyway. Is it not possible/legal for you to
    just provide the libraries already built and ready-to-go for download,
    along with the most basic instructions necessary to link them into the
    application?

    Anyway, at the end of the day, you need to test-drive the tutorial on
    some newbies. If you find that they are happy to follow all the
    instructions you give just to create their first
    programmatically-generated image, then all's well and good, and you
    can ignore our carping cynicism!
    Dylan Nicholson, Feb 23, 2005
    #10
  11. * Dylan Nicholson:
    >
    > Is it not possible/legal for you to
    > just provide the libraries already built and ready-to-go for download,
    > along with the most basic instructions necessary to link them into the
    > application?


    It is possible, and also legal, but that is of no use to someone who needs
    some other library. It's also possible to make the creation of a word-
    processor a one-click option. For example. ;-)

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Feb 23, 2005
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alf P. Steinbach
    Replies:
    13
    Views:
    657
    Alf P. Steinbach
    Feb 1, 2005
  2. Alf P. Steinbach
    Replies:
    7
    Views:
    3,054
    chris
    Jan 24, 2005
  3. Alf P. Steinbach
    Replies:
    2
    Views:
    523
    Alf P. Steinbach
    Feb 22, 2005
  4. Alf P. Steinbach
    Replies:
    0
    Views:
    576
    Alf P. Steinbach
    Feb 22, 2005
  5. Alf P. Steinbach
    Replies:
    25
    Views:
    952
    Thomas Hansen
    Apr 11, 2005
Loading...

Share This Page