20th
Compiling libfbml for Facebook Open Platform on Ubuntu
Heard a lot of people saying that this Facebook Open Platform’s libfbml compiles fine on Fedora Core 6 and CentOS, but since I favour Kubuntu for it’s ease of management, I decided to go with it. Follow the install procedures right and check the whether you’ve got all the dependency libs installed or else you will run into a lot of errors. I screwed up one ubuntu install and two kubuntu installs because of doing the wrong stuff.
I also tried installing Gentoo in-between and I didn’t even pass the Gentoo install. Gentoo seems to be for pros. So I got back on Kubuntu. The following install is done on Kubuntu 8.04. It should work on all Ubuntu flavours (and forks too).
This blogpost assumes you can manage to play around with the terminal and have a basic knowledge of vi too (if not just refer some online tutorial while you edit the file. It’s only a few keystrokes and fun). And you’ll have to be daredevil enough to perform some stunts like editing the /usr/include files and and do some rocknrolla. After all this blogpost will save you two days of time.
Copy the 14 downloaded packages as per the Facebook Open Platform release notes to the dependencies dir in the libfbml dir. Do not use any updated versions of those libraries. This way you’ll avoid a lot of problems.
Apart from those there are a few more things that should be checked.
- libexpat1-dev
- zlib1g-dev
- g++ 4.2
- libjpeg62-dev
- xorg-dev
- bison
- byacc
- php5-dev (yeah not ‘php5’)
- x11proto-render-dev
- libxml2-dev
- gettext
- flex (This one is a fast lexical analyzing tool. This is not Adobe Flex.)
I use Kubuntu 8.04 and the above were available from the ubuntu repo. So just use your package manager to get these if you use any flavour of Ubuntu.
I strongly recommend avoiding the use of the build-all.py file which the readme in libfbml recommends. Ofcourse if you know a bit of python you can make build-all.py do the stuff for you but with a little bit of tweaking. If you want to play safe, just follow the blog post.
Now just untar each of those libs in the dependencies dir and do the following on eash of those packages.
./configure
make
sudo make install
This is an exception for libXft, Xrender and firefox which is explained below.
When you are abt to fo ./configure for glib, wait, cd into the untared dir of glib, and find modules/printbackends/cups/gtkcupsutils.c and fire up a text editor to edit that file.
In the beginning of the file find the following
#define HAVE_HTTP_AUTHSTRING 1
Change it to…
// #define HAVE_HTTP_AUTHSTRING 1
You are just commenting out the line. :)
And once before and after you compile and install the glib, do an to do a sudo ldconfig. Or else you are mostly bound to receive an error regarding the pkg-config modversion returning Glib version 2.16.6 while you have 2.16.3.
If you run into errors relating to Xrender.h, add the x-include path option for configure of libXft and xrender. For all Ubuntu flavours the path would be /usr/include
The configure command should now look like this should look like this
./configure —x-include=/usr/include
If that fails use the same path with the x-libraries option also with the above.
After this is done, you are most likely to get errors related to render.h (file found but not able to compile) or renderproto.h or render(version is too old to use). Now you’ve got to edit the file in /usr/include/X11/extensions/render.h (preferbly using vi editor) so that should be…
sudo vi /usr/include/X11/extensions/render.h
Find the following var initiations…
typedef XID Glyph;
typedef XID GlyphSet;
typedef XID Picture;
typedef XID PictFormat;
Change it to…
typedef unsigned long Glyph;
typedef unsigned long GlyphSet;
typedef unsigned long Picture;
typedef unsigned long PictFormat;
That sounds like a temporary solution to me. This the permanant solution would be to find and include the header file which contains definitions for XID. But there’s isn’t going to be any problem with editing this file. The doing sudo apt-get install render-dev indicates that this file and it’s package is obselete and is replaced by Xrender which is included in the OS’s latest render lib, which is x11proto-render-dev in our case since we are using Kubuntu 8.04. Just took a look at the bug logs at the debian site. Bug or not, that doesn’t concern us though (we just need the fb platform running right?).
Now we should begin doing with the mozilla HTML parser thing (which I often refered to as firefox, coz it is firefox what we are messing with). Now cd to you home($HOME) dir and create a file .mozconfig with the following content. You’ll have that file already if you have firefox or something of mozilla installed. No problem. JUst go ahead and replace that file. You want to get that facebook platform running right?
.$topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-opt
mk_add_options MOZ_CO_PROJECT=browser
ac_cv_visibility_pragma=no
ac_add_options —prefix=/usr
ac_add_options —with-system-jpeg=/usr/lib
ac_add_options —with-system-zlib=/usr/lib
ac_add_options —with-system-png=/usr/lib
ac_add_options —enable-default-toolkit=gtk2
ac_add_options —enable-application=browser
ac_add_options —enable-xinerama
ac_add_options —disable-accessibility
ac_add_options —disable-installer
ac_add_options —disable-tests
ac_add_options —enable-places
ac_add_options —enable-safe-browsing
ac_add_options —enable-xterm-updates
ac_add_options —enable-cpp-rtti
ac_add_options —enable-reorder
ac_add_options —enable-system-cairo
Now untar the firefox package and do a configure and make. While doing configure just be sure that you do it with the following options.
./configure —enable-application=browser —enable-system-cairo
If you are using the 64-bit version of Ubuntu, then find the text “os_Linux_x86.o” in the build-all.py file and change it to “os_Linux_x86_64.o”. Open the Makefile in the libfbml dir and again do the same text edit. The Makefile I’m refering to is in the one in the same dir as the build-all.py file.
It looks like some moron wrote the code for the fbml.cpp file in the src dir. Find where the goto label ‘exit’ and whereever it’s used (it’s used twice). Re-write the code to use if statements.
Open the file rules.mk in the libfbml dir. find the following and delete it:
ifndef NO_WERROR
CXXFLAGS += -Werror
endif
Thats because the Werror option tells GCC to treat all warnings as errors.
Edit the build-all.py file so that it doesn’t do configure and make for any of the dependency packages including firefox, because you’ve already done it manually. Edit it in such a way so that it starts after the end of the firefox part and run it. It will now do the rest for you perfectly.
Your libfbml is now ready. You now have it as a php extension fbml.so Restart your apache server and you’ll find your fbml extension loaded (edit your php.ini file and include the extension fbml.so). That ends the buggy part. Follow the README in the fbopen pkg to get the Open Platform working fully.
Thanks to rchennau for a list of things to check out. But I just figured out that a lot more than those need to be checked and done to get the whole thing perfectly running. :)
My Bookmarks