Deployment on Linux

From GNUstepWiki
Revision as of 15:47, 11 November 2011 by Julian (talk | contribs)
Jump to navigation Jump to search

Deploying a GNUstep-using application is easy if it is intended for inclusion in linux distributions or if you are deploying in an controlled environment, e.g. in the enterprise. However there are a number of reasons why you would need to create end-user deployable packages that already include GNUstep:

• your application depends on features that are not included yet in linux distributions (libobjc2, llvm, /recent/ GNUstep versions)
   or on a patched GNUstep version or you want to be sure your application is only used with a specific GNUstep theme...
• you want to offer your self-contained binary version of your application for download without having your users need to install GNUstep (e.g. commercial apps)

In this case its best to bundle GNUstep with your application binary. First off you need to decide on the oldest linux distribution you want to support, since compiled binaries often do not run on older linux versions than they were built on. I am using Ubuntu 10.04 LTS for this purpose.

When you have installed this distribution you first need to take care of the dependencies of GNUstep itself, that you do not want your resulting installation to depend on. For example most distributions ship without libffi, so if you want to use a libffi-enabled GNUstep you need to statically link it or ship it in your download. This guide assumes you've built static versions of libffi, libpng, liftiff and libxml2 and installed them into: ~/build/ (on AMD64 you *must* build all libraries --with-pic else they won't work)

Now you need to compile standalone versions of GNUstep. These instructions depend on at least revision 34026 of GNUstep to work - as of October 2011 there have been no releases of GNUstep with the necessary features and fixes therefore you need the SVN version. It is also a good idea to configure GNUstep to use only the bare minimum of the features that you need - e.g getting problems because GNUstep depends on libjpeg although you aren't using it can be avoided.

Optional: Install LLVM >= 2.9 as compiler

Checkout GNUstep SVN:

 svn co http://svn.gna.org/svn/gnustep/modules/core

Install GNUstep make:

 cd core/make
 ./configure --with-layout=standalone
 make && make install

Source GNUstep envionment:

 . ~/standalone/Makefiles/GNUstep.sh 

Optional: Install libobjc2 if you need a modern runtime e.g. for blocks support. You need to configure and install GNUstep make a second time after installing libobjc2 if you decide on using it, in order for it to get picked up. Note that libobjc2 > 1.5.1 doesn't install itself into the GNUstep environment by default anymore, so you need to take care it gets installed into ~/standalone/: PREFIX=~/standalone/ make install

Build GNUstep base:

 PATH=$PATH:~/build/bin ./configure --with-config-file=./ --with-default-config=standalone.conf --with-include-dir=~/build/include/ --with-library-dir=~/build/lib/ --with-ffi-include=~/build/include/ --with-ffi-library=~/build/lib/
 make && make install


Build GNUstep gui:

 ./configure --with-tiff-include=~/build/include/ --with-tiff-library=~/build/lib/ --disable-jpeg
 make && make install

Build GNUstep back (you need to install development packages for X11 and libart - depending on cairo is probably a bad idea):

 ./configure
 make && make install


Success, now you have a standalone GNUstep environment in ~/standalone/

Next step is installing the Themes you want your application to use into ~/standalone/Themes/ since the default look will probably anger your users. The best choice for deployment on linux is probably the gnome-theme for nice system integration but this may create problems with library dependencies across distributions so i've settled on the Silver theme for now.

Place a file named GlobalDefaults.plist into ~/standalone/ to change the Theme, make GNUstep use horizontal menus like everyone else and change other options:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//GNUstep//DTD plist 0.9//EN" "http://www.gnustep.org/plist-0_9.xml">
<plist version="0.9">
  <dict>
	<key>GSTheme</key>
	<string>Silver</string>
	<key>NSMenuInterfaceStyle</key>
	<string>NSWindows95InterfaceStyle</string>
	<key>NSUseRunningCopy</key>
	<string>YES</string>
	<key>GSSuppressAppIcon</key>
	<string>YES</string>
  </dict>
</plist>

Now just build your application (cd AppSource; make), move the standalone folder into your application bundle, place a launcher script next to your application bundle, compress the application bundle and the launcher script and place it somewhere for download. Don't forget to test the result on a variety of distributions.

Sample application launcher script:

 export LD_LIBRARY_PATH=`pwd`/YourApplicationName.app/standalone:$LD_LIBRARY_PATH
 exec YourApplicationName.app/YourApplicationName


There is one more issue with deployment on linux: 64 / 32 bit compatibility. On Mac OS X and Windows you can just deploy a 32-bit package and it will run fine on 64-bit too. On 64-bit linux you can run 32-bin binaries too, but the 32-bit libraries are not installed by default and its only easily possible to install 32-bit libraries on Fedora but not on Debian/Ubuntu. Therefore your only options are either to:

• build a 32-bit package and link *everything* statically so it runs fine on 64-bit too where the libraries are missing.
• build gnustep and your app in a 32-bit and a 64-bit version and select the proper version in your launcher script (or host 2 different packages for download).