[HOWTO] Compile Facebook hiphop-php in Fedora 15

HipHop for PHP is a source code transformer which transforms PHP code to C++ and compiles it with gcc/g++. I wanted to experiment with it and tried to install in on my PC with Fedora 15. Here is how I did it and how you can do it ( hopefully 🙂 ). Please note that this did not work and I will update the article soon.

Install Dependencies Available in the Repos
In the terminal, run the following command:

su -c 'yum -y install git cmake boost pcre-devel libicu-devel libmcrypt-devel oniguruma-devel mysql-devel gd-devel boost-devel libxml2-devel libcap-devel binutils-devel flex bison expat-devel re2c tbb libmemcached-devel tbb-devel bzip2-devel openldap-devel readline-devel libc-client-devel pam-devel gcc-c++ memcached'

Setup build environment
I compiled it in dev folder of home directory. Change directory in subsequent commands if you are doing it somewhere else. Run the following commands:

cd
mkdir -p dev/local

Download hiphop-php

cd
cd dev
git clone git://github.com/facebook/hiphop-php.git

Download, patch and compile libcurl and libevent
Use these versions because as of current, patches for these versions are only available in hiphop git.

cd
cd dev

wget http://curl.haxx.se/download/curl-7.20.0.tar.bz2
wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xvzf libevent-1.4.13-stable.tar.gz
tar xvjf curl-7.20.0.tar.bz2

export CMAKE_PREFIX_PATH=`pwd`/local

cd libevent-1.4.13-stable
cp ../hiphop-php/src/third_party/libevent-1.4.13.fb-changes.diff .
patch < libevent-1.4.13.fb-changes.diff
./configure --prefix=`pwd`/../local
make install
cd ..

cd curl-7.20.0
cp ../hiphop-php/src/third_party/libcurl.fb-changes.diff .
patch -p0 < libcurl.fb-changes.diff #see note-1 below

Note-1: While patching curl, you may be asked paths to the files. Enter includes/curl/multi.h and lib/multi.c respectively.

Now, you will need to make a small change in Makefile for it to compile properly. To do that open the file src/Makefile in gedit or any text editor, find the line that has the following:

curl_LDADD = $(top_builddir)/lib/libcurl.la -lz

and append -lrt so that the line looks like the following:

curl_LDADD = $(top_builddir)/lib/libcurl.la -lz -lrt

Now, run the following in the terminal:

cd
cd dev/curl-7.20.0
./configure --prefix=`pwd`/../local
make install
cd ..

Compile hiphop-php

cd
cd dev
export CMAKE_PREFIX_PATH=`pwd`/local
cd hiphop-php
git submodule init
git submodule update
export HPHP_HOME=`pwd`
export HPHP_LIB=`pwd`/bin
cmake . #see note-2 below
make #see note-3 below

Note-2: You may get errors while running cmake. This may be because of dependencies I might have missed above. In that case, please let me know the output of cmake in the comments so that I might be able to help.
Note-3: If you encounter any errors while using make, remove CMakeCache.txt and run make clean, cmake and make again.

This should have worked, but I am getting the following error:

../../bin/libhphp_runtime.a(ext_mysql.cpp.o): In function `HPHP::php_mysql_do_query_general(HPHP::String const&, HPHP::Variant const&, bool)':
ext_mysql.cpp:(.text+0x8100): undefined reference to `cli_safe_read'
ext_mysql.cpp:(.text+0x826a): undefined reference to `net_field_length'
ext_mysql.cpp:(.text+0x83a0): undefined reference to `cli_safe_read'
ext_mysql.cpp:(.text+0x8712): undefined reference to `free_root'
collect2: ld returned 1 exit status
make[2]: *** [src/hphp/hphp] Error 1
make[1]: *** [src/hphp/CMakeFiles/hphp.dir/all] Error 2
make: *** [all] Error 2

It seems like a problem with mysql version in the Fedora repo. I will download and build mysql and update this post.

Further Reading
https://github.com/facebook/hiphop-php/wiki/running-hiphop

References
https://github.com/facebook/hiphop-php
http://www.ioncannon.net/programming/918/building-hiphop-php-for-fedora-12-on-64-bit-and-32-bit-systems/
http://comments.gmane.org/gmane.comp.web.curl.library/29278

[SOLVED] No package ‘gtk+-3.0’ found

If you are trying to compile a gtk-3 application and if you don’t have development package installed here is the error you can get:

configure: error: Package requirements (gtk+-3.0 >= 3.0.0) were not met:

No package ‘gtk+-3.0’ found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GTK_CFLAGS
and GTK_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

If you encounter this error in Fedora, you should install gtk3-devel. In terminal, type in the following:

su -c 'yum install gtk3-devel'

If you encounter this in Ubuntu, you should install libgtk-3-dev. To do so, type in the following in terminal:

sudo apt-get install libgtk-3-dev

Hope this helps.

[HOWTO] Install GPaste in Fedora 15

GPaste is a clipboard management tool for GNOME 3. It is not available in the repos and must be downloaded via git and compiled. Here is how you can do it:

UPDATE:
GPaste is now available in the repos, so you can install it by using Add/Remove Programs or by running the following commands in the terminal:

su
yum install gpaste

That should install GPaste. The following post is for historical reasons only.


Install Git

su -c 'yum install git'

Download GPaste sources

cd; git clone https://github.com/Keruspe/GPaste.git

Install Dependencies

su -c 'yum install gtk3-devel glib2-devel intltool automake autoconf vala'

Compile and Install

cd;cd GPaste
./autogen.bash
./configure --prefix=/usr
make
su -c 'make install'

Restart GNOME Shell
To restart, press Alt+F2, enter ‘r’ (without quotes) and press enter.

You should now see GPaste icon in the top panel.

[HOWTO] Open djvu files in Fedora 15

Support for djvu files is not included in Fedora default installation, however, it can be installed from the repository. To add djvu support to the default document viewer (Evince) run the following in terminal:

su -c 'yum install evince-djvu'

If you want to install a different reader for djvu files, you can do so by installing djview. To install djview, type in the following in terminal.

su -c 'yum install djview4'

Hope this helps.

[HOWTO] Make Street Bike Fury run in Windows 7

I had played a great indie game a few years back. It was called Street Bike Fury from S64 Games. The game is no longer being developed because of death of the developer. I had tried to make this game run earlier but failed. However, I have found a way now and I would like to share that.

After some research, I found that the game was developed using Game Maker 6. The programs made in this only run in Windows XP and not in Windows 7 and Windows Vista. However, in YoYoGames Wiki, there is a software that can fix this. First download and setup Street Bike Fury from official download page. Then, download the Game Maker Conversion Program from here. Then setup the game but don’t launch it. Use the GM_Convert_Game and patch the exe. Then you will be able to run it.

Hope this helps.

[HOWTO] Install Linux Kernel 3.0 in Ubuntu 11.04 Natty Narwhal

Linux Kernel 3.0 RC 1 was recently released. Although it does not have real changes to anything, but is just a renaming of 2.6.40, however, you may want to install it for testing and using it if it works good for you in your Ubuntu Natty installation. It has bug fixes and additional drivers so it may solve problems. However, it may also introduce new problems, so be careful not to remove the other kernel (2.6.38) after installing it. This tutorial also contains instructions to remove it safely, so read along. Ubuntu 11.10 Oneiric Ocelot will be released with kernel 3.0.

As of writing this, only amd64 (64 bit version) of the kernel is available in Kernel PPA, so if you are using 32-bit, it will not work for you. However, if you find i386 builds in the kernel ppa, you can install it. (UPDATE: Now both 32-bit and 64-bit versions are available)

First of all, download the debs from Kernel PPA. Then install in this order:
linux-headers
linux-headers-generic
linux-image

Once installation is done, reboot and Ubuntu should boot into 3.0 by default. If everything works right, you may want to keep it, however, if it does not, don’t worry, just reboot and select one of the previous versions and boot into it. Then open up synaptic, search for linux-headers-3 and linux-image-3 and remove the 3.0 versions.

If you are reading this after other versions are released, you may want to check out kernel ppa.

[HOWTO] Install VirtualBox 4.0 in Fedora 15

Here is how you can install VirtualBox in Fedora 15. Open up the terminal and type in the following commands (make sure you have enabled sudo for your user):

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | rpm --import -
sudo wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo --output-document=/etc/yum.repos.d/virtualbox.repo
sudo yum install VirtualBox-4.0 dkms

Hope this helps.

20 Things to do after installing Fedora 15

Here are few things you can do after installing Fedora 15 to make the experience better. You may have to enable sudo to follow some of the tips or you can run the commands in terminal by logging in as root (su). The following are in no particular order. Feel free to skip the ones you do not need.

1. Enable sudo

2. Install yum-fastestmirror plugin
yum-fastestmirror selects the fastest mirror for updating and installing packages. It can be installed by running the following in the terminal:

sudo yum install yum-fastestmirror

3. Add shutdown menu item permanently

4. Install flash player

5. Add minimize, maximize title bar buttons

6. Enable delete key in Nautilus

7. Enable right click on desktop and add Desktop folder on the Desktop

8. Show date on top panel

9. Install nautilus open terminal
If you use terminal a lot, you may want to have “Open in terminal” in folders in Nautilus file manager. To do so, install the package nautilus-open-terminal

sudo yum install nautilus-open-terminal

10. Install a torrent client
If you download via torrents, you will need a torrent client. While Fedora ships with Transmission Torrent Cliene, I prefer Vuze (Azureus) (written in Java). It can be installed by running the following in the terminal:

sudo yum install azureus

You may also like deluge (written in Python, Gtk) which is also an excellent alternative. It can be installed by running the following in the terminal:

sudo yum install deluge

11. Install Google Chrome
Although Firefox 4 is shipped by default, you may want to have a secondary browser or may prefer Google Chrome. You can simply download rpm from Google Chrome download page and install it. The package will automatically insert repository information so that you get updates from update manager.

12. Install Libreoffice
Libreoffice is available in the repository. I recommend “Add/Remove Software” to select and install office tools you need. libreoffice-writer (Word processor) and libreoffice-calc (Spreadsheet) is all I need. You may also want libreoffice-impress (Presentation) and libreoffice-draw (Drawing).

13. Install Thunderbird
I prefer Thunderbird to Evolution. You can install it from repository by running the following in the terminal:

sudo yum install thunderbird

14. Install a clipboard manager
If you do a lot of writing or programming, you will love a clipboard manager. I like parcellite and it is available in the repos as well. It can be installed by running the following in the terminal:

sudo yum install parcellite

UPDATE: You may also like another clipboard manager called GPaste which integrates well with Gnome Shell.

15. Install Google Voice and Video chat
If you use Google Voice, you can download and install rpm package from Google Voice and Video Download page.

16. Add support for media formats

17. Install support for rar and 7z archive formats
Rar is a proprietary format but it is used widely and you may encounter rar files so it is handy to have it installed.

sudo yum localinstall --nogpgcheck http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
sudo yum install unrar

7z is also a popular format and it is also available in the repository.

sudo yum install p7zip p7zip-plugins

18. Install Gimp
Fedora does not ship with an image editor. I prefer Gimp and it can be installed by running the following in the terminal:

sudo yum install gimp

19. Install gnome-tweak-tool to customize fonts, themes etc
gnome-tweak-tool can be installed by running the following in the terminal:

sudo yum install gnome-tweak-tool

Run it (press Alt+F2 and type in gnome-tweak-tool) and change the settings. It does not have OK or Apply and simply selecting the options performs the changes. Some changes may require logging out and logging back in.

20. Install skype
Skype is a popular text, voice and video chat tool. You can download and install rpm from this link. If you have 32-bit, installation will be straightforward. However, if you have 64-bit, please read this post.

Please share what you did after installing Fedora 15 in the comments.