HOWTO Get XCB (and) Cairo Running ================================= Felix Rabe , 21 April 2008. The quick-and-fast document to read to compile XCB and Cairo (with XCB). Even though you only need to read through this document, I provide outside pointers so you can double-check the information I worked into it in case something doesn't work for you the way it is written here. Skip to "First Step" below or lose precious time reading my rants (included here because I'm basically too lazy to write them down separately). Why don't I just contribute to the outdated Wiki entries? Because there are quite a few of them and I don't want to mess with the consistency of outdatedness in each entry. I would have to invest more time to bring them up-to-date, so I prefer to have at least something random googlers can find and (hopefully) use to some extent. My background or why I wrote this in the first place: I have no clue about xorg, and I want to innovate beyond current GUI toolkits like GTK+ and Qt (I know them both). I found out about XCB and understand that it is The Way To Go. I also wrote a small application with Cairo (+Gtk) already and want to use this on xorg, so I want to be able to use Cairo with XCB. I will probably later on write a tutorial on Cairo+XCB. This is a cool project: http://research.sun.com/projects/lively/ . I currently cannot use it in Firefox 3 (Beta) though (only a small strip at the top is visible, but that shows me it basically works), and also I think that the Web and the Web browser is the wrong place to implement this. It might be neat for now, but it clearly cannot be the long-term direction to take. The developers of the Lively Kernel themselves wrote long papers about their experiences and findings building that thing and this tells me: the Web is not the place to build upon; there needs to be a more coherent / simple / portable / extensible replacement for the whole stack of HTTP/HTML/CSS/XML/JavaScript/DOM/SVG/... , and I think Cairo can (for now at least) play an important role in this. Of course, the technologies individually are works of art, but IMO the Web forces them to play together in incoherent ways. That's why e.g. Flash is so popular: it gives you declarative and procedural programming and an editing environment in one, more or less coherent package. I don't have authoring experience with Flash though. Cairo's sources contain the 'INSTALL' file, which will guide you through the Cairo compilation and installation once we have all the prerequisites (XCB) in place. http://xcb.freedesktop.org/DevelopersGuide/ http://www.linuxfromscratch.org/blfs/view/svn/x/xcb-proto.html http://www.linuxfromscratch.org/blfs/view/svn/x/libxcb.html Maybe: http://www.linuxfromscratch.org/blfs/view/svn/x/xorg7.html http://wiki.linuxfromscratch.org/blfs/wiki/Xorg7 I wanted to avoid it (huge document), but well... http://xorg.freedesktop.org/wiki/ModularDevelopersGuide First Step ---------- From this: http://xorg.freedesktop.org/wiki/ModularDevelopersGuide#head-a085b56a4b98f5418566ff5f575ca47805bd54c6 save this: http://xorg.freedesktop.org/wiki/ModularDevelopersGuide?action=AttachFile&do=get&target=git_xorg.sh Apply (using 'patch' or manually; and avoid looking at the timestamp please, thank you): --- git_xorg.sh~ 2008-04-21 12:24:14.000000000 +0200 +++ git_xorg.sh 2008-04-21 12:02:01.000000000 +0200 @@ -135,6 +135,7 @@ do_dir xorg data "${data}" do_dir xorg doc "${doc}" do_dir xorg driver "${driver}" +do_dir xorg font "${font}" # this line added to get fonts do_dir xorg lib "${lib}" do_dir xorg proto "${proto}" do_dir xorg util "${util}" Run: $ mkdir some/place/xorg ; cd some/place/xorg $ sh path/to/git_xorg.sh Skip to "What do we need to build now?" once the download is complete. Wait a while. Get some coffee, play guitar, read lwn.net, read userfriendly.org, do something productive, watch a movie about Linux kernel internals. Invent jokes. Or just wait. This is not Git's fault; xorg is just huge and has many modules, which makes the download take a while. Go find a nice short tutorial on Smalltalk on the web and read it. It's like learning Python, just faster, and fun to learn a solid programming language in just 30 minutes :) (Ok, it did take me a bit longer than that, but given the right tutorial, you should be able to get into it pretty fast.) What do we need to build now? ----------------------------- According to http://xcb.freedesktop.org/DevelopersGuide/ , now that I checked out all the modules, I need to build + install some of them. How to build? http://xorg.freedesktop.org/wiki/ModularDevelopersGuide#head-c35264aacf77e77caeca305a1a9a3da3be6e4fa5 Just skip to 'What do we need to build now? #2', as using 'build.sh' looks like overkill on my quite recent Ubuntu system. Aaah, I just hate stuff like this note: Note: The build script does not currently build xcb/pthread-stubs. This package is a default requirement for xcb. You may have to edit build.sh or the xcb configuration to reflect this. (Btw, this is not even the case anymore. I guess this statement is outdated.) Funny, 'xcb/pthread-stubs' is mentionned on: http://xcb.freedesktop.org/DevelopersGuide/ Maybe use jhbuild? -> http://xorg.freedesktop.org/wiki/JhBuildInstructions These instructions assume that you're already familiar with jhbuild and how to use it. No, I'm not, so back to the build script method: http://xorg.freedesktop.org/wiki/ModularDevelopersGuide#head-70b76cfa443105aa56b0c3d98615ae7d4f32c452 Oooh, go have a look at 'util/modular/COPYING'. This raises a big red legal question mark in my mind: am I supposed to read the code and do something with it at all or not? Ok, now reading the 'build.sh' file there. (Don't forget to run this through 'indent' or configure your editor to use a tab width of 8.) Looks like I just need a subset of all that. Modify heavily. (Looking at stuff like 'build_driver_video()' makes me wonder: Do I really have to build all those drivers that I won't need? Probably not. And then I just want libxcb.la anyway, not the whole xorg server package.) Comment about line 294: I think this should be done in software, as dependencies will change sooner or later anyway. Ok, back at the Modular Developers Guide, I see I will run the final script something like this: $ cd ~/xcb-cairo/build/xcb $ PATH=~/opt/xcb-cairo/bin:$PATH ./util/modular/build.sh -n -D ~/opt/xcb-cairo 2>&1 | tee build.log ('tee' because I want to see what's going on.) Question: what is this '$DESTDIR' variable about? Hmm, line 737: PATH does not need to get set... What do we need to build now? #2 -------------------------------- Following: http://xorg.freedesktop.org/wiki/ModularDevelopersGuide#head-539708fdedddd7994203e866475f03b5b16d38eb (IIRC, I had to install automake, autoconf, libtool, various-xorg-stuff-dev beforehand.) First, xorg/util/macros: $ cd ~/xcb-cairo/build/xorg/util/macros $ export P=~/opt/xcb-cairo $ ./autogen.sh --prefix=$P && make && make install $ export PKG_CONFIG_PATH=$P/lib/pkgconfig $ export ACLOCAL="aclocal -I $P/share/aclocal" Now repeat the './autogen --prefix=$P && make && make install' step for each mentioned module in http://xcb.freedesktop.org/DevelopersGuide/ . libxcb (make) complains: 'Failed to load the xcbgen Python package!' (The instructions in the Wiki refer to 'build.sh' and './configure' options for complex packages.) Further it gives solution tips: create a *.pth file or set PYTHONPATH. I chose the latter: $ export PYTHONPATH=~/opt/xcb-cairo/lib/python2.5/site-packages Building Cairo -------------- $ git clone git://anongit.freedesktop.org/git/pixman $ cd pixman $ ./autogen.sh --prefix=$P && make && make install $ git clone git://anongit.freedesktop.org/git/cairo $ cd cairo Look at Cairo's README file whether you have all the necessary dependencies. $ export LD_LIBRARY_PATH=$P/lib # necessary at this stage? $ export LIBDIR=$P/lib $ ./autogen.sh --prefix=$P --enable-xcb && make && make install