How to Compile

Software is usually written in programming languages, certain sets of rules and syntax styles that tell the computer what to do. In order to make the computer able to run those commands, they must be translated into binary language: that's compiling.

The devx module contains a compiler, GCC, and all the headers and development files of packages that come included with Puppy; you'll need it to compile source code. Also, you'll need to be familiar with the console and Puppy to some degree.

Typically, the procedure used to compile a piece of software consists of 6 steps:

  1. Downloading the sources,
  2. Unpacking the sources,
  3. Creating a makefile,
  4. Compiling,
  5. Installing,
  6. Deleting the sources.

Downloading the Sources

First of all, download the source code you wish to compile from the project's site and place it in a directory.

In this example, I will compile Xournal, a nice notes and sketches application. First of all, I downloaded the sources from the Xournal homepage to /root/xournal.

Unpacking the Sources

Then, open a console window and cd to the directory containing the sources.

Then, unpack the sources:

  • For gzip-compressed sources (with the .tar.gz extension), use the command “tar xzvf <sources>”.
  • For bzip2-compressed sources (with the .tar.bz2 extension), use the command “tar xjvf <sources>”.

In my case, it's gzip compression, so I did the following:

cd /root/xournal
tar xzvf xournal-0.4.5.tar.gz

Creating a Makefile

Now, cd to the unpacked sources directory. In my case:

cd xournal-0.4.5

To generate a makefile, run the following:

./configure --prefix=/usr

Most packages should be configured with a “–prefix=/usr”, which moves all their files to /usr, in order to comply with the File System Heirarchy.

However, if you wish to share the compiled software, you should use a slightly different command instead:

./configure --build=i486-pc-linux-gnu --prefix=/usr CFLAGS="-mtune=generic -O2 -fomit-frame-pointer" CXXFLAGS=$CFLAGS

That ensures compatibility with other computers.

Sometimes, Puppy is missing some dependencies and the configuration fails. In such cases, run the following:

./configure --help

This will give you additional parameters and options. Add useful parameters and disable things you don't want until the configuration passes. For instance, to successfully compile Pidgin (a multi-protocol instant-messaging client) on Puppy some parameters that disable additional features must be used, otherwise it won't work.

Compiling

In order to compile the sources, run Make.

make

If you own a multi-core processor, run the following, with N as the number of cores:

make -jN

For instance, with a dual-core processor, use “make -j2”.

Installing

In order to install the newly compiled binaries, use the following:

make install

That will install the package locally. In order to uninstall it, use the following:

make uninstall

However, in order to install the package to a directory and not to /, use this command:

make DESTDIR=<directory> install

That will install the package to <directory>. This is extremely useful for creating SFS extensions or PET packages from it.

Deleting the Sources

When you're done compiling and installing, you can delete the sources, as they take much space.

In my case,

cd ..
cd ..
rm -r xournal
 
compile.txt · Last modified: 2010/05/08, 11:16 by iguleder
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki