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

  • Thread starter Alf P. Steinbach
  • Start date
A

Alf P. Steinbach

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
 
T

Thomas Hansen

Alf said:
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
 
A

Alf P. Steinbach

* 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. :)
 
D

Dylan Nicholson

* Thomas Hansen:

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!
 
A

Alf P. Steinbach

* Dylan Nicholson:
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?
 
I

Ioannis Vranos

Alf said:
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.
 
T

Thomas Hansen

Alf said:
* Thomas Hansen:

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
 
A

Alf P. Steinbach

* Ioannis Vranos:
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

Alf P. Steinbach

* 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).
 
D

Dylan Nicholson

* Thomas Hansen:

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!
 
A

Alf P. Steinbach

* 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. ;-)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top