What I Learned from Smoking Clover

I was browsing through the “The New Hackers Dictionary” (http://www.eps.mcgill.ca/jargon/jargon.html), a version of the “Jargon File” (https://en.wikipedia.org/wiki/Jargon_File) when I discovered a entry for Smoking Clover, a display hack attributed to Bill Gosper. I located a copy on SourceForge and downloaded it, and unzipped it into a src directory. Looked routine.

Not.


me@here:~/Projects/Graphics/SmokingClover$ cd src
me@here:~/Projects/Graphics/SmokingClover/src$ make
-g -Wall `gtk-config` --cflags -c -o clover.o clover.c
/bin/sh: 1: gtk-config: not found
In file included from clover.c:1:0:
clover.h:47:21: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
: recipe for target 'clover.o' failed
make: *** [clover.o] Error 1
me@here:~/Projects/Graphics/SmokingClover/src$/

make did not. The Makefile that comes with the Smoking Clover packages does not make the clover package. Why not?

Well, I know that gtk is installed. What’s wrong with this picture.

What’s in the Makefile?

me@here:~/Projects/Graphics/SmokingClover/src$ cat Makefile
CFLAGS = -g -Wall `gtk-config` --cflags
LIBS = `gtk-config` --libs

SRCS = README COPYING ChangeLog BUGS Makefile *.[ch]

CLOVER_OBJS = clover.o common.o direct.o true.o rgb.o
clover: $(CLOVER_OBJS)
$(CC) $(CFLAGS) -o clover $(CLOVER_OBJS) $(LIBS)
$(CLOVER_OBJS): clover.h Makefile

tar:
tar -cf - $(SRCS) | gzip > clover.tar.gz
clean:
rm -f *.o clover
me@here:~/Projects/Graphics/SmokingClover/src$

Maybe no path to gtk-config …

me@here:~/Projects/Graphics/SmokingClover/src$ locate gtk-config
/usr/share/icons/breeze/apps/32/preferences-gtk-config.svg
/usr/share/icons/breeze-dark/apps/32/preferences-gtk-config.svg

Not promising.

A google or two and still no real answer…

Let’s try something… executing gtk-config.

me@here:~/Projects/Graphics/SmokingClover/src$ gtk-config --cflags
No command 'gtk-config' found, did you mean:
Command 'gts-config' from package 'libgts-bin' (universe)
gtk-config: command not found
me@here:~/Projects/Graphics/SmokingClover/src$

Another google and a hit on StackOverflow provided a hint:

Use pkg-config instead of gtk-config. While the article in Stack Overflow did not say so, gtk-config was for GTK 1.0. GTK 2.0 changed that.

me@here:~/Projects/Graphics/SmokingClover/src$ pkg-config
Must specify package names on the command line

Now we are getting someplace.

me@here:~/Projects/Graphics/SmokingClover/src$ pkg-config gtk-2.0 --cflags
Package gtk-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk-2.0' found

Or better, spell gtk+-2.0 correctly.

me@here:~/Projects/Graphics/SmokingClover/src$ pkg-config gtk+-2.0 --cflags
-pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2

That’s better. Change the Makefile to include the pkg-config lines

me@here:~/Projects/Graphics/SmokingClover/src$ head Makefile -n 3
CFLAGS = -g -Wall 'pkg-config gtk+-2.0 --cflags`
LIBS = `pkg-config gtk+-2.0 --libs`

me@here:~/Projects/Graphics/SmokingClover/src$ make
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o clover.o clover.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o common.o common.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o direct.o direct.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o true.o true.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o rgb.o rgb.c
rgb.c: In function ‘rgb_init’:
rgb.c:28:31: warning: pointer targets in passing argument 1 of ‘gdk_rgb_cmap_new’ differ in signedness [-Wpointer-sign]
rgb_cmap = gdk_rgb_cmap_new (colors, 256);
^
In file included from /usr/include/gtk-2.0/gdk/gdkpixbuf.h:36:0,
from /usr/include/gtk-2.0/gdk/gdkcairo.h:28,
from /usr/include/gtk-2.0/gdk/gdk.h:33,
from /usr/include/gtk-2.0/gtk/gtk.h:32,
from clover.h:47,
from rgb.c:1:
/usr/include/gtk-2.0/gdk/gdkrgb.h:128:13: note: expected ‘guint32 * {aka unsigned int *}’ but argument is of type ‘gint32 * {aka int *}’
GdkRgbCmap *gdk_rgb_cmap_new (guint32 *colors,
^
rgb.c: In function ‘rgb_redraw’:
rgb.c:58:9: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
countp = counts;
^
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -o clover clover.o common.o direct.o true.o rgb.o `pkg-config gtk+-2.0 --libs`
/usr/bin/ld: direct.o: undefined reference to symbol 'floor@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:8: recipe for target 'clover' failed
make: *** [clover] Error 1
me@here:~/Projects/Graphics/SmokingClover/src$

Close but no cigar.

Looking at the first error found, something called “floor” is undefined at link time. floor … looks like a math function, maybe not to you but I’ve had an interesting life.
A google hit includes the function ceil. A math function. The article suggests you add libm.

You are in a room … you see a libm. take libm

me@here:~/Projects/Graphics/SmokingClover/src$ head -n 3 Makefile
CFLAGS = -g -Wall `pkg-config gtk+-2.0 --cflags`
LIBS = `pkg-config gtk+-2.0 --libs` -lm


me@here:~/Projects/Graphics/SmokingClover/src$ make
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o clover.o clover.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o common.o common.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o direct.o direct.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o true.o true.c
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -c -o rgb.o rgb.c
rgb.c: In function ‘rgb_init’:
rgb.c:28:31: warning: pointer targets in passing argument 1 of ‘gdk_rgb_cmap_new’ differ in signedness [-Wpointer-sign]
rgb_cmap = gdk_rgb_cmap_new (colors, 256);
^
In file included from /usr/include/gtk-2.0/gdk/gdkpixbuf.h:36:0,
from /usr/include/gtk-2.0/gdk/gdkcairo.h:28,
from /usr/include/gtk-2.0/gdk/gdk.h:33,
from /usr/include/gtk-2.0/gtk/gtk.h:32,
from clover.h:47,
from rgb.c:1:
/usr/include/gtk-2.0/gdk/gdkrgb.h:128:13: note: expected ‘guint32 * {aka unsigned int *}’ but argument is of type ‘gint32 * {aka int *}’
GdkRgbCmap *gdk_rgb_cmap_new (guint32 *colors,
^
rgb.c: In function ‘rgb_redraw’:
rgb.c:58:9: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
countp = counts;
^
cc -g -Wall `pkg-config gtk+-2.0 --cflags` -o clover clover.o common.o direct.o true.o rgb.o `pkg-config gtk+-2.0 --libs` -lm
me@here:~/Projects/Graphics/SmokingClover/src$

WHOA!

make is made!

Smoking Clover now. Or more correctly, the clover executable has been created.

transparent 4 leaf clover in transparent green and magenta
Here is how clover executes on my system

Try it, you’ll like it.

Discussion:

This program is clearly ancient history. What I have discovered since is that gtk-config was the tool used in gtk-1.0 and was replaced in gtk+2.0. No hint of this was in any of the information that I found using the information that I had at the time. Young-in’s, no sense of history.
I also went down a false path (that I cannot seem to reproduce) that required that I add the names of the include files to some of the c header .h files. In reproducing my quest, this did not seem to be necessary. Go figure.

The pointer sign-ed-ness warning may or not be important. It should be fixed. In my experience warnings are there for a reason and the results may be unpredictable. I found some hints as to how to fix it but have not yet gotten to it.

The tag line “No smoke, no odor, not a sound” is from a radio commercial in the late 1960’s from the East Ohio Gas Company touting gas fired domestic incinerators. Refer to the Summary item 5. The jingle was very catchy and memorable. Additional interesting, related stuff

Model: Optimist Pram

Optimist Pram model on model sawhorses.  Centerboard, rudder, and sail are in profile in this side view.
Side view of completed model of Optimist Pram.
I recently completed a model of an Optimist Pram in 1 inch=1 foot scale. It seems that as with many projects, the preparation takes longer than the project. I found plans. First I used the lumber inventory to rummage through my pre-cut wood. Not all of the required pieces were available so I cut the rest by hand. Next, the building frame.A view of the building frame with the transom, center bulkhead, and forward transom in place and connected at the edges by the chines and in the center by the 'keel' and bottom reinforcement pieces. Setting up the actual boat frames was complicated. If you were doing it full size, you could use a tape measure and level or plumb-bob. As it was getting the measurements set up in the middle-of-thin-air took some clever clamp-measure-move-reclamp action to get it just right over several days as I had to wait for the glue to dry to do the next frame. I think that the center bulkhead is 1/16″ off-square which would be 1/2″ in full size.
Once the frames were set up, the corners were notched and the chines and keels were set in. A little sanding to shape.
The side glued and clamped to the chine and rail on the building frame.  The clamps are small clothes pins.
The side glued and clamped to the chine and rail.
Next the sides were put on as rectangles then trimmed with a coping saw and sanded with 60-grit to fit. and finally the bottom.
The rudder and centerboard were next along with the mast, boom, and sprit. Finish is varnish.
The sail was laid out with a program named Sailcut. It neatly lays out panels perpendicular to the leech givin a very realistic appearance to the modeled sail. The “eyelets” are dots of gold sparkle-pen ink.
This view from slight to the rear and right side shoes the interior of the boat.  The actual boat is 7 and 1/2 feet long.  The model is about 7 1/2 inches long and 4 inches wide.  The front is square, not pointed which is the pram shape.  The hull is slightly narrower in the front, bows out amidship and tapers slightly to the transom.
A view from slightly above with scale.

Traveling Salesman Problem Lectures

This week I was able to attend 2 lectures by Professor William J. Cook, Chandler Family Professor, ISyE, Operations Research, Georgia Institute of Technology at Furman University’s 2011-2012 Donald H. Clanton Visiting Mathematician Program. 

Exact Solutions in Linear and Integer Programming

This lecture treats the problem of finding exact rational solutions.  While the details of the mathematical theory cannot be covered in a one hour lecture, Professor Cook was able to help the audience (me at least) understand the difficulties inherent in the computer’s limited numeric precision, the large number of calculations involved each with its inherent possible losses, and a number of approaches to reducing or at least managing these errors. With David L. Applegate, Robert E. Bixby, and Vasek Chvátal, William J. Cook is co-author of The Traveling Salesman Problem: A Computational Study

In Pursuit of the Salesman: Mathematics at the Limits of Computation

This lecture is  more accessible by the non-mathematician.  Professor Cook outlines the history and origins of the problem: How to minimize the length of the trip a salesman must make to visit all of the required cities.  The complexity of this problem grows super-exponentially with each added point. With delightful illustrations, pictures, and explanation he makes this problem come alive and helps us understand why the Traveling Salesman Problem is important not just to travelers but in genetics, manufacturing and astronomy.

Professor Cook’s book In Pursuit of the Salesman: Mathematics at the Limits of Computation be available in January, 2012.

If you have an opportunity to hear Professor Cook speak, do not miss it. You will enjoy his knowledge and excitement in mathematics.

Clean Thinking

So just exactly what is the composition of Dust Bunnies?  Clearly an understudied science.  I believe that when the truth comes out, that Dust Bunnies will have a fabric content of insect or more likely arachnid  origin.  Part of some small animal’s quest for food, be it airborne, flying, or crawling.  Or maybe nest for food for offspring.  Somebody else’s grant to write, I’m having fun here in the exciting, dust free world of Information Technology.

http://greatvines.com/buy–cheap-accutane

Progress Widget

A while ago, I posted that I was learning about GTK and more important (to me), GTK for C++.  I have been carefully working through the tutorial.  The way I learn best is by preparing to teach others.  I have been taking notes and creating some exercises which I will contribute back to the GTKmm project when I get them into decent shape.  I have worked through the entry widgets and next is the progress widget.

In the mean time, my wife, a sometime  techno-phobe, asked me to help her purchase an online airline ticket.  Not a big deal.  An hour later, we have a printed ticket at a price that is not prohibitive. My wife, who had not heard the joke before, was amused by the phrase “World Wide Wait”.  Forty-five minutes of the ticket time was spent looking at what I call a “spinner” and some at what techies call a “progress bar”.

The spinner is a screen that acts like it is doing something while you are waiting.   The spinner that might be part the browser.  If it were the cursor on your system, it would slow down or freeze when the local system is waiting for resources.  Other times they hang because they are waiting for a remote, synchronous service like a firewall or a security check. But usually, they are just blinky lights, like the ones that used to chase each other around the marquee at the neighborhood theater until they burned out and nobody replaced them.

More important is the “progress bar”. Or more precisely, the lack-of-progress bar.  This is supposed to move along steadily and indicate how close the web page is to being complete.  I usually see it rush quickly toward half-way.  Then slow down until at 75%, the progress becomes nil.  Finally, after a time twice as long as the wait to half-way, a message box appears that the request cannot be completed due to a condition the user cannot do anything about.  The message never suggests that the web host capacity planner has been sleeping in his chair after a beer at lunch or that that the host DBA meant to re-org the database last month but was at the beach.

And so I propose the “lack-of-progress bar”.  This little gem, when embedded in your web page will not only entertain you by advancing in a non-monotonic way, arbitrarily falling back to a lesser state as the http under-covers encounters adversity, it will put out a meaningful message, pointing the finger at the actual cause of the delay, be it end-point host, local system, or the ISP.  If there are multiple culprits, it will name them all.

Wait there is more! If supplied with the appropriate information, it will simultaneously, write a letter to the U.S. Representative, both Senators, the President, the FCC, the ICC, the DHS, and least effective  but most annoying the TSA. It will  Twitter a spurious rumor about the failing service provider, and a short sale order to your broker.

Or maybe it will meet the release date deadline.  But probably not both.

Shakin’ it up here boss.

New Old LP's

My wife went to a Thrift Shop in Minnesota and sent home a pile of LP’s. They have been sitting waiting to be played, filed or discarded for a couple of months.  On a slow news day, I took the first one off the pile and played it.  Ray Confiff Memories Are Made of This.  S’ Typical.  A Scandinavian looking woman on the cover wearing a pastel purple bulky sweater, studying some small artifact.  A bunch of guys that sound like trombones.  A bunch of gals that sound like trumpets.  And Billy Butterfield who actually plays the trumpet on Love Letters in the Sand. Doc Severinson plays trumpet on Three Coins in the Fountain.

Next, completely off the radar, The Dell Trio – Cocktail Time – Harmony (a product of Columbia Records). An apparent re-release of a 1949 album.  Cornball?  If there is a single recording that defines cornball, this is it.  Lawrence Welk, move over.  A sweet (in the diabetic sense) combination of accordion, Hammond, and jazz guitar.  Percussion free.  Who needs drums when you have an accordion?  A quick Google shows that this album may still be popular with some and that someone thinks it might, just maybe, if it don’t take up space in his inventory too much longer, be worth $10.  Mighty clean copy, missing a sleeve.  I didn’t know they ever made records like that.  Whoa!

Nightmare Exam II

The Religion (HUM112) mid-term exam consists of one question:

The number of angels  on the head of a pin is which one of the following:

A) an integer

B) a real number

c) an imaginary number

d) an irrational number

Provide a formal proof.

Schlagers

I usually let the music “On the Player” speak for itself. I comment on “Schlagers” because of the fabulous talent that Warner Bros was able to bring together. Joni Mitchell, Mike Post, Frank Sinatra, Miriam Makeba, Vince Guaraldi (not playing Peanuts or Cast Your Fate to the Wind). I put this on because I asked my wife “Suggest some music that we don’t play much”. “What about those collections that I used to get”. Yes, Schlagers is a Promotional Album. Not to be sold. Basically for the cost of shipping, you got half-a-party of music for $3 (barely covered shipping).  From back when Warner Bros  had something worth promoting.  And they promoted the dickens out of it.  Promotion is euphemism for sharing.  For free.  Thank you Ms. Elaine Geller for many happy hours.  I presume that Ms. Geller ran the fulfillment office.  I hope that she is happily and richly retired.  And that she has sold her stock in that loser Warner Bros and the other scum companies that are members  of what the RIAA has become.

Furman and Scottish Games

I opened the Summer issue of the Furman alumni magazine only to find a picture of my neighbor. (Unfortunately, the webmaster cannot keep up with the print publication and and there are many broken links besides). I would post links to the pics but cannot. Please make do with this scan.

John Burton (left) explains the details of the Austin-Healey 100 engine.
John Burton (left) explains the details of the Austin-Healey 100 engine.