Why is it so hard to have some libraries installed?

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.


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.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.