Monday, 24 March 2008

Howto install KILE on Mac OS X natively

Mission: install Kile on Mac OS X, natively, no X11 emulation
Even though kde4 made me reconsider positively the gnome desktop environment, the aspect i like most is the possibility of installing kde apps on non linux systems!
and one of the aspects i love of mac is that almost any linux program can be installed!
However when you use a lot a program it can become annoying that you have to run X11 first, then start the app from command line and in the end you get a program not very well integrated with the system.
So i though i could compile the necessary libs for installing my favourite kde application: KILE
which for me is the _best_ latex editor.
You can use it with X11 all the way, but if you want more, follow this guide.

0. The easy wayThere is a shortcut to almost all the procedure described, that is, download and install the snapshots of Racoon Fink and compile kile like in section 3; however the svn versions usually work better when they are all svn, mixing version may produce unexpected surprises.
So if you want the quick (so to speak since you're gonna download ~3GB from torrents) and easy way follow the guide located here and proceed to section 3; for the bravest of you out there continue reading.
If you wish, you can test both methods on the same machine as they won't interfere.

1. Requirements
If you want the latest release of kde, you are very brave, or you want to learn something, this is the right path!

1.1 Fink
So first of all you need fink which is a nice easy and clean way to obtain all the basic dependecies we need. As a general rule, when you're missing some program or lib, just type

fink install
and you are ready to go!
I'm not covering how to install fink (because it is really simple) nor which dependency you actually need (because i don't know, as i believe i've installed almost any packet fink offers :P) [but you can see here some hints]

1.2 QT (updated)
Then you surely need QT-4.4, which recently exited beta, any previous version won't work. To make things easier you can directly take the qt-copy package, a patched version of qt for compatibility with KDE.
So obtain the patches from svn with
svn co svn://
Access the directory and then compile and install
./configure -dbus-linked -no-accessibility -no-qt3support -optimized-qmake -no-3dnow -qt-gif -release -prefix /opt/qt4.4 -openssl make sudo make install
I put quite parameters trying to tweak performance a little bit. If you want to go in details:
  • -dbus-linked is needed by latest release, or kdelibs will complain
  • -no-accessibility since we're install qt for kile we can set this off, but it can be useful for some other applications
  • -no-qt3support as qt3 works with X11 only, it's something we can deactivate
  • -optimized-qmake should turn on some random optimizations
  • -no-3dnow only available in AMD cpu
  • -qt-gif was present in the official guide, so it shouldn't be harmful :P
  • -release removes unnecessary debug symbols (don't do this if you want to develop on the qt!)
  • -prefix /opt/qt4.4 i want third party stuff installed in /opt to resemble a Linux fs :)
  • -openssl for some strange reasons, kdelibs won't start compiling if openssl not enabled in this way
1.3 CMake
One last requirement is CMake (>2.7) that you can obtain with the following commands
(if asked for a password type "cmake")
cvs -d login cvs -d co CMake
and compile as usual
cd CMake ./configure --prefix=/opt/kde4-deps-svn make sudo make install
2. Installing KDE4 You need a couple of packets before we can install kile: kdelibs, kdepimlibs and kdebase.Optionally you can install kdesupport which contains soprano, strigi and some other dependency we might need later. One important step is to configure correctly the necessary environment variables. As a minimum you need to do
export PATH="/opt/qt4.4/bin:/opt/kde4-svn/bin:/opt/kde4-deps-svn/bin:/opt/fink/bin:$PATH" export CMAKE_LIBRARY_PATH="/opt/kde4-deps-svn/lib:/opt/fink/lib" export CMAKE_INCLUDE_PATH="/opt/kde4-deps-svn/include:/opt/fink/include" export PKG_CONFIG_PATH="/opt/qt4.4/lib/"
(i installed fink in /opt/fink, change your variables accordingly) 1.1 kdelibs For me kdelibs was the most difficult part of the whole process because for some reason it did not compile easily; however after some checkouts later it did compile with no problems. As usual perform
svn co svn://
and in the same directory where you run that command
because cmake wants to build stuff in a separate folder from the source and the .build will keep spotlight indexing away. Now run
cd cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4-svn -Wno-dev -DCMAKE_BUILD_TYPE=Release sudo make install
1.2 kdepimslibs Then the other parts are quite straightforward, apart some dependecy missing. So let's fix them first: do
fink install gpgme11 boost1.33
while the rest is just like before
svn checkout svn:// mkdir cd kdepimlibs.buildcmake ../kdepimlibs -DCMAKE_INSTALL_PREFIX=/opt/kde4-svn -Wno-dev -DCMAKE_BUILD_TYPE=Release sudo make install
1.2 kdebase This one was a little tricky because for a bug it says Blitz is missing while in reality it wants qimageblitz!If you installed kdesupport you should already have this, but for all the others, do
svn checkout svn:// mkdir cd qimageblitz.buildcmake ../qimageblitz -DCMAKE_INSTALL_PREFIX=/opt/kde4-deps-svn -Wno-dev -DCMAKE_BUILD_TYPE=Release sudo make install
Note that this is being installed in the -deps folder; if you want to use the whole kdesupport, remember to install it there! For those who didn't install kdesupport, remember that strigi and soprano are required for this packet! Now we can install our nice kdebase, the last requirement for Kile! We don't need it whole, just the runtime and optionally the apps part! Just perform
svn checkout svn:// mkdir cd kdebase-runtime.buildcmake ../kdebase/runtime -DCMAKE_INSTALL_PREFIX=/opt/kde4-svn -Wno-dev -DCMAKE_BUILD_TYPE=Release sudo make install cd .. mkdir cd kdebase-apps.buildcmake ../kdebase/apps -DCMAKE_INSTALL_PREFIX=/opt/kde4-svn -Wno-dev -DCMAKE_BUILD_TYPE=Release sudo make install
and you can successfully proceed to step 3! 3. Kile, finally! Now that we've got everything we need, we can happy download and install Kile natively, without X11 emulation! The svn reported on the website is for the stable branch, we're going to need something more extreme! Obtain the source from
svn co svn://
and compile it like you did with every packet till now
mkdir cd kile.buildcmake ../kile -DCMAKE_INSTALL_PREFIX=/opt/kde4-svn -Wno-dev -DCMAKE_BUILD_TYPE=Release sudo make install
Now go to /opt/kde4-svn/bin and there you will find your Kile app, ready to be run! You can move it into the Application folder to get along with the other apps and use this nice icon to flavor it up! 4. Be happy (almost) We're done! we have our favourite app running natively on our computers! Wait something is missing! The quickbuild & co. don't seem to work! Yep that's because mac are a little different from linux apps and it's more difficult to set up a correct environment for them! But do not worry! there is a solution for anything! Download and install Platypus from here. This tool is a wrapper for mac application to behave like real bsd programs! I'll describe the simple step to make our kile fully running, for more information, visit the site at the end of this guide. Open Platypus, give a name to the application (namely, Kile), select Shell script type and choose a new Script Path. In the editor that appears you have to write your path you have set in the everyday bash (echo $PATH) and the command line call for kile. Since we're going to use this script for launching kile i suggest you move the Kile app in the Application folder to somewhere you don't visit often, like Utilities/TeX (at least, that's were i put it mine). Now write in the editor
#!/bin/bash export PATH="(your path here)" /Applications/Utilities/TeX/
ans press Save. Now, before clicking Create, select the option "Runs in background" so we won't have the script icon hanging in the Dock. All done! Click Create, put a nice icon to the script (the one of before) and here we go! A fully working Kile editor! Remember that there's still some tuning to do, like setting the Preview application instead of kpdf, but after compiling half kde i'm sure you're willing to perform this last step :) Hope you enjoyed this little guide and if you liked it, you can publish it anywhere you want as long as you link it here! If you find some errors or don't like something, please contact me or leave a comment! PS Credits: here is the two guides i took most of for writing mine

All the projects here are under a Creative Commons 3.0 licence! You can use and distribute them as you like (just quote the author so he knows his work is not useless)!

If you wish to get in touch with me write at