Failing at the easiest things – e.g. printing

Printer by the OatmealThis post was originally written on December 3rd, but I forgot to publish it.

If you want a funny version if this, go read „Why I believe printers were sent from hell to make us miserable“ by the Oatmeal. If you want to know how well printers succeeded at the task of making me miserable, read on…

I just want to moan about the miserable feeling that I get when even the easiest things fail. I think this is because in most cases, I just can’t figure out if it’s just those things that fail, or if it’s me.

One such thing is printing. I have to hand in several homeworks per week, and being the kind of nerd I always was, I prefer to write the solution on a computer, using LaTeX. In this portable environment, it can’t even shock me if my laptop breaks, because there’s always some other machine around that can process LaTeX. And while there always may be problems with how to typeset a given formula, a solution can always be found. In the ideal case, I can find it in 2 minutes with google, but even when I struggle for 30 minutes, this comes with a certain feeling of pride, having achieved something, having learned a valuable piece of knowledge for the future.

Then I have to print it, which can be done on one of 12 printers at my university. It either works, which really isn’t enough to give me a real, intense, fuzzy warm feeling. Or, if it doesn’t work, it fails. I hit print, and nothing happens. Or, I hit print, and it says „done“, but the paper just isn’t there. Or, I hit print, it says „processing“, says this for about 20 minutes (while the printer actually does nothing), then it forgets my order and prints something else for someone who’s luckier than me.

No matter in what way it fails, a true solution lies beyond my reach. Yeah, I could buy myself a printer, but that involves money… you guess the problem. Everything else is just not under my control. So I come to the university early, planning more than 1 hour to print 3 (!!) pages of black and white text. Given more time, I can always try again to print. Which I always have to pay for, probably even when it fails.

Today, I spent more than 1,5 hours printing my three pages. I used 4 university PCs in 2 rooms, 6 printers in 3 rooms, my own OQO UMPC, and a PC in a copy shop which had about 20 printers, but failed even more than the entire university gear.

I had to hand in my homework 40 minutes late, causing considerable overhead for my professor and his assistant, who was already gone with the homeworks which were handed in on time. It was ok, but of course I don’t know home many times it will be OK in the future. And even though he didn’t say anything nasty, it gave me the feeling of having failed. Having failed personally, on a trivial task. And without any trace of a proof, I guess everybody else manages to print things on time. Well, call me a pussy for that, as I could just forget about it and be happy.

But the aftermath is, that the additional time I spent printing, was initially planned to do another homework and hand in some even more important papers to the university. My schedule just is too packed to reserve 5 hours a week just for printing some pages. As you might suspect, the responsible office was closed by the time I had my homework printed. And, guess what, I already planned to hand this in yesterday, but I first had to print it, and by the time this was done, well the office was also closed. So I have to go there the next time they open, which leads me to missing at least one lecture – plus the two I missed yesterday by printing. Which is ok, because when I don’t hand in those papers by tomorrow, all my lectures and homeworks and everything is meaningless anyway.

And slowly I come to the bitter conclusion, that my entire life might eventually fail, not because of big catastrophes, but because of the accumulation of small failures, adding up beyond the sum that the society is able to compensate.

So you might find my personal misery and its nasty details rather uninteresting or even annoying. Everybody thinks so, and because of that, I can’t reply to questions like „Why did you hand in your homework late?“ with an answer like „Yeah, you know [insert the whole blog post here], that’s why.“ Instead, the answer would be more like „Because I’m an idiot who can’t even manage the most simple things in life, that’s why.“ I might want to add „There’s also a good reason for it, but you wouldn’t want to know the details.“ In the end, I start to believe that I’m that idiot.

And you might ask from where I take the time to think and write about it. Well, while waiting for my printouts, of course.

So, whats the end of the story? Finally, I ended up with my document, that is, three copies of that document, and eventually found 7 more copies of the papers I wanted so print yesterday, scattered through the printer rooms. I guess there are 4 more copies of my homework on their way, too. Hooray.

Note from today: I might want to add that I bought a printer some weeks later, and now I’m floating in endless happiness.

Why is it so hard to have some libraries installed?

Edit: I asked a related question on stackoverflow.com, but since it was „not programming related“ (!!!) is was moved over to superuser.com, where I got a nice answer and an even nicer comment to the answer. Now I know that „apt-file“ can figure out which library to install, and 90% of my usual lib-install-sorrow is cured by this nice tool. Anyway, some cases remain where I just have to give up. You can read more about it here.

I feel completely lost each time I have to fulfill the dependencies of some C or C++ code.

I really do understand C, C++, static and dynamic libraries, header files and linking, as well as the packet manager „aptitude“ but when it comes to the practical part, I have absolutely no idea what to do.

I mean, I know what to do on a theoretical level, and most of the time, I can even archive it. But over the year’s, I got so much better in all aspects of programming, but concerning library dependency resolution, I still feel like the 6 year old boy writing his very first for-next-loop. After going though this trouble so many times, there still is no pattern, no deterministic approach to follow, just desperate  fiddling around and running in circles.

First of all, I think it must be possible to get this libraries as a recompiled binary. If I had to compile them myself, I would be stuck in a recursive problem because I had to fulfill their dependencies, which involves compiling them as well, but first… I feel there must be something in between getting only the end-user executable and getting the full source of without binaries.

Sometimes, I manage to find a download, but it doesn’t say where to put it. So I prefer a packet manager, but that does not make it easier at all.

You might be tempted to say: It’s not that hard. Well, it is. If you don’t believe, read on.

Just an example

I will introduce an example to explain my problem, but really, I don’t ask for a specific solution for those three libs, I want some deeper understanding of how to approach that problem in general. I experienced the same with many more libs, and I remember having the same general problems when I was still using windows.

Three little libraries

I want to use code which states that „It utilizes glib2, curl and openssl“ – it does not say anything else about it. All of that libs are absolutely standard, so it shouldn’t be hard at all to get them. I think this means I need static libraries from those projects, as well as header files. In the source I want to use, there is

#include <curl/curl.h>
#include <openssl/md5.h>
#include <glib.h>

And none of them is found at compilation time. I never know if this is really a missing file, or just misconfiguration of my build process, so each time I end up doing a fully recursive file search on my whole hard drive to see if those files are present anywhere. This time, they aren’t. Of course, I knew that I need to somehow get glib2, curl and openssl onto my computer. I think I can install them via apt-get.

So I tried sudo apt-get install curl openssl (let’s forget about glib for a moment). Still there is no curl.h on my system and all md5.h instances on my system have nothing to do with openssl. I know that some packages have variants with suffixes like -dev, -devel, -src, -source or a lib- or lib prefix, but I never know which to choose, and sometimes there are none of those at all.

Installing curl (and, by pure chance, also openssl)

For curl, there is the choice between curl, curlftpfs, flickcurl-doc, flickcurl-utils, gambas-gb-net-curl, gambas2-gb-net-curl, gimp-libcurl, gnupg-curl, libcurl-ocaml, libcurl-ocaml-dev, libcurl3, libcurl3-dbg, libcurl3-gnutls, libcurl3-gnutls-dev, libcurl3-openssl-dev, libcurl4-gnutls-dev, libcurl4-openssl-dev, libflickcurl-dev, libflickcurl0, libghc6-curl-dev, libghc6-curl-doc, libghc6-curl-prof, liblua5.1-curl-dev, liblua5.1-curl0, libwww-curl-perl, php4-curl, php5-curl, python-pycurl, python2.4-pycurl, slang-curl, spl-curl, tclcurl, xmms2-plugin-curl and somehow I figured out that libcurl3-dev sounds nice, but how do I really know? In the end, this also installed libcurl4-openssl-dev and got me a matching version of openssl’s md5.h.

Lucky me, bacause I wouldn’t have known which one to chose from openssl, aolserver4-nsopenssl, globus-openssl-progs, libcrypt-openssl-bignum-perl, libcrypt-openssl-dsa-perl, libcrypt-openssl-random-perl, libcrypt-openssl-rsa-perl, libcrypt-openssl-x509-perl, libcurl3-openssl-dev, libcurl4-openssl-dev, libengine-pkcs11-openssl, libengine-tpm-openssl, libglobus-gsi-openssl-error-dev, libglobus-gsi-openssl-error-doc, libglobus-gsi-openssl-error0, libglobus-openssl, libglobus-openssl-dev, libglobus-openssl-module-dev, libglobus-openssl-module-doc, libglobus-openssl-module0, libopenssl-ruby, libopenssl-ruby1.6, libopenssl-ruby1.8, libopenssl-ruby1.9, libopenssl-ruby1.9.1, libpathfinder-openssl-1, libxmlsec1-openssl, openssl-blacklist, openssl-blacklist-extra, openssl-doc, pyopenssl-doc, python-openssl, python-openssl-dbg, python-openssl-doc, python-pyopenssl, python2.4-pyopenssl, since there is no -dev package with a generic name for openssl.

glib

But still, this leaves me without glib, which is not to be confused with glibc. There are no matching packets, only glibc-doc and glibc-source. Starting from the reference page, I think there is no logical way I could find a download without using a search engine, but via google I managed to download a copy at http://www.gtk.org/download-linux.html – but it forced me to sudo apt-get install gettext in order to ./configure and make. It has dependencies on 6 other libraries, and I don’t want to think about what would have happended if I lacked those.

I think it’s worth saying that during this compilation, make called another make, which called bash, which called another bash, which called make, which called another make, which called bash, which called another bash, which called make, which called gcc which in turn called gc1. Is this depth of recursion really needed to build a low level helper library?

Whatever. After this, I have a glib.h in /usr/local/include/glib-2.0/. After adding this path to the include directory of the preprocessor, I end up with 363 errors inside glib’s header files. And with not a single idea how this is possible.

This is the standard case.

I’m totally used to create a hello world project, include a single .h file (like windows.h in the old Microsoft days) and start „fixing“ 23 errors in that header. I can’t really believe there are real errors in major headers like windows.h but on the other hand, I don’t remember any project without them. Normally, it takes about 2 hours until my hello word can be compiled again, but from that point on, I can program anything I like without hitting any trouble.

But facing 363 errors, I’m completely convinced that

#include <iostream>
#include <curl/curl.h>
#include <openssl/md5.h>
#include <glib.h>

int main()
{
    std::cout << "Hello shit";
}

is better left as it was, without encrypted network access.