The Source for Java Technology Collaboration


INSTRUCTIONS FOR BUILDING JXTA-C ON LINUX/UNIX

1) About this document

  • You should read and understand this document completely before going any further.
  • This document was originally prepared on 9/5/07.
  • You should be aware that the information in this document may become obsolete at any time.
  • This document is by no means complete.
  • This document does not attempt to explain all possible situations.
  • This document does not provide information for building JXTA-C on Microsoft Windows. Although, some information contained herein may apply to building JXTA-C on Microsoft Windows.

2) Overview

  • This document provides you instructions for building JXTA-C on Unix/Linux platforms.
  • This document was based upon experiences of building JXTA-C on a Fedora Core 6 platform. Building JXTA-C on other Unix/Linux platforms may differ.
  • This document provides you information about building the latest JXTA-C: from the official release tarball, and from JXTA-C Subversion repository.
  • This document will walk you through the process of: getting, patching, configuring, compiling and installing; JXTA-C and its dependencies.
  • This document leans toward building dependencies from source code, rather than installing developer's packages.
  • This document provides guidance regarding the compilation and installation of third-party libraries.

3) Dependencies

  • JXTA-C makes use of several third-party open-source libraries and build-tools.
  • You should read the document titled JXTA-C DEPENDENCIES before going any farther.

4) Third-party Libraries

  • For JXTA-C to function, third-party libraries must be installed and configured properly.
  • You must install and configure third-party libraries before building JXTA-C.
  • The following third party libraries are necessary for JXTA-C to function: apr, apr_util, OpenSSL, sqlite, libxml, expat.
  • The zlib library is optional; however, you should build JXTA-C against zlib if you want compression.
  • You should build apr_util, sqlite and libxml from source code.
  • You should build and install the libraries in the order presented in this document.
  • If you have problems building third-party libraries you should visit the library's website for build information and troubleshooting tips.
  • Except for libraries that must be built from source, you should try building and testing JXTA-C against your platform's pre-installed libraries before migrating to a particular library version.
    Library Build From Source Patch Required Homepage
    sqlite YES NO http://www.sqlite.org
    libxml MAYBE MAYBE http://xmlsoft.org
    apr NO NO http://apr.apache.org
    apr_util YES YES http://apr.apache.org
    openssl NO NO http://www.openssl.org
    zlib NO NO http://www.zlib.net
    expat NO NO http://expat.sourceforge.net

5) Get JXTA-C source code

  • This section only explains how to get the JXTA-C source code.
  • It is necessary to get JXTA-C source code before continuing because the JXTA-C source contains a patch that libxml may require.
  • Section 12 explains how to build and install JXTA-C.

  • You have two options for getting the source code:
    • GOTO Section 5.1 to get the latest JXTA-C official release source archive.
    • GOTO Settion 5.2 to get development code from the Subversion Repository.

  • The jxta-c svn repository contains a main trunk an a couple of branches.
  • Some developers, who are actively developing certain jxta-c features, may want to build from a branch.
  • Most developers will want to cd down into the trunk directory and build from there.
  • Use this option if you are interested in:
    • compiling current development code (trunk).
    • compiling from a development branch.

5.1) Download the official release source archive.

  • Point your browser to http://download.java.net/jxta.
  • Scroll down the page to the JXTA-C section.
  • Download the tarball that you are interested in.
  • Unpack the tarball. For example:
      tar -xvf jxta-c-2.5.2.tar.gz

5.2) Check out from Subversion

From you shell's command prompt type:
      svn checkout https://jxta-c.dev.java.net/svn/jxta-c/jxta-c/trunk jxta-c --username guest

6) Installing OpenSSL

  • You probably have OpenSSL already installed on your system, be sure you also have the OpenSSL developer pack "openssl-devel" installed.
  • The information provided here is just in case you need to install OpenSSL or build the source code.

6.1) Installing OpenSSL Binaries

6.1.1) Automatic package installer

  • Read Appendix A for more info.
  • Example of installing a particular version of OpenSSL and developer pack using YUM:
      $ yum install openssl-0.9.8b-8
      $ yum install openssl-devel-0.9.8b-8

6.1.2) RPM package

  • The OpenSSL website contains no RPMs. RPMs may be supplied by other sources.
  • Locate the RPM package of interest.
  • Copy the openssl and openssl-devel RPM files that you require to your hard-drive.
  • cd to the directory where you downloaded the files
  • Now login as root and install the files.

6.2) Building OpenSSL from Source (Usually not necessary, but just in case you need to do this)

6.2.1) Tarball

  • Point your webbrowser to http://openssl.org/source/
  • Locate the tarball of the version you are interested in building.
  • Download the tarball to your system.
  • Extract the source from the tarball. For example:
      $ tar -xvf openssl-0.9.8d.tar.gz

6.2.2) SRPM

  • The OpenSSL website contains no SRPMs.
  • Locate the SRPM package of interest.
  • Copy the SRPM file that you require to your hard-drive.
  • cd to the directory where you downloaded the file
  • Now login as root and install the files.
  • Extract the resulting tarball.

6.2.3) Configuring, Building, Installing

  • cd into the directory containing the Makefile for openssl.
      ./config
      make
      su
      make install
      exit
  • You should make a note of which directory OpenSSL got installed to.

7) Installing Zlib

  • The presence of zlib is optional for building JXTA-C.
  • You probably have Zlib already installed on your system, be sure you also have the zlib developer pack "zlib-devel" installed.
  • The information provided here is just in case you need to install OpenSSL or build the source code.
  • If you have zlib installed and you want JXTA-C to use it, you should configure JXTA-C with the --enable-compression=no and --enable-decompression=no options. Otherwise, omit these options from the JXTA-C configure command.
  • You should verify that your system has at least the minimum required zlib version installed.
  • If necessary, you should upgrade your zlib installation

7.1) Installing zlib Binaries

7.1.1) Automatic package installer

  • Read Appendix A for more info.
  • Example of installing a particular version of OpenSSL and developer pack using YUM:
      $ yum install zlib
      $ yum install zlib-devel

7.1.2) RPM package

  • The OpenSSL website contains no RPMs. RPMs may be supplied by other sources.
  • Locate the RPM package of interest.
  • Copy the zlib and zlib-devel RPM files that you require to your hard-drive.
  • cd to the directory where you downloaded the files
  • Now login as root and install the files.

7.2) Building zlib from Source (Usually not necessary, but just in case you need to do this)

  • GOTO 7.2.1 if you want to get the tarball.
  • GOTO 7.2.2 if you want to get the SRPM.

7.2.1) Tarball

  • Point your webbrowser to http://zlib.net
  • Locate the tarball of the version you are interested in building.
  • Download the tarball to your system.
  • Extract the source from the tarball. For example:
      $ tar -xvf zlib-1.2.3.tar.gz

7.2.2) SRPM

  • Locate the SRPM package of interest.
  • Copy the SRPM file that you require to your hard-drive.
  • cd to the directory where you downloaded the file
  • Now login as root and install the files.
  • Extract the resulting tarball.

7.2.3) Configuring, Building, Installing

  • cd into the directory containing the Makefile for zlib.
      ./configure
      make
      su
      make install
      exit
  • You should make a note of which directory zlib got installed to.

8) Building sqlite

  • You are strongly advised to build sqlite from the source code instead of installing it from a binary.
  • Why? Because, the sqlite binary packages are compiled with thread safety turned off.
  • To be guaranteed a thread-safe sqlite installation you must compile from source code.

8.1) Get sqlite source code

  • You have three options for getting sqlite source code:
    • GOTO Section 8.1.1 to get the latest release of sqlite
    • GOTO Section 8.1.2 to get a version from the sqlite CVS repository.
    • GOTO Section 8.1.3 to get Source RPM package or Source DEB package.

8.1.1) Getting the latest sqlite released version

  • Point your web browser to http://www.sqlite.org/download.html
  • Scroll down to the "source code" section of the sqlite download page.
  • Locate the tarball that contains the complete source tree. For example: sqlite-3.4.2.tar.gz.
  • Download the tarball to your harddrive.
  • Unpack the tarball. For example:
      tar -xvf sqlite-3.4.2.tar.gz

8.1.2) Getting sqlite from the sqlite CVS repository

  • Note: If you go through this method and you get build errors, you may want to try another method.
  • Point your web browser to http://www.sqlite.org/cvstrac/rlog?f=sqlite%2FVERSION&sms=1
  • Search the milestones for the version you are interested in.
  • Click on the link next to the "Milestone" you are interested in. For example: click on the "3831" link for version 3.3.15 and you will see http://www.sqlite.org/cvstrac/chngview?cn=3831
  • When you get to the milestone page, make a note of the UTC time/date stamp. For example: 2007-Apr-09 13:49:34 (UTC) .
  • Replace the month in the UTC time/date stamp with the equivalent month number. For example 2007-04-09 13:49:34 (UTC) .
  • Remove the parentheses in the UTC time/date stamp 2007-04-09 13:49:34 UTC
  • At your shell's command prompt type:
      cvs -d :pserver:anonymous@www.sqlite.org:/sqlite login
      cvs -d :pserver:anonymous@www.sqlite.org:/sqlite checkout sqlite
      cd sqlite
      cvs update -D 'put time/date stamp here date here' #For example cvs update -D 2007-04-09 13:49:34 UTC

8.1.3) Getting sqlite from Source RPM or Source DEB

  • Search the web for the desired source RPM. Here's a good place to check for earlier SRPM versions (http://rpm.net.in/mirror/i386-linux/SRPMS/).
  • Download the package.
  • Login as root.
  • Install the source package.
  • If the installed package contains a tarball, extract the files from the tarball.

8.2) Configuring sqlite

  • cd into the directory containing the sqlite code.
  • You have two options for configuring the sqlite code:
    • GOTO Step 8.2.1 to build sqlite with the thread-safe option enabled.
    • GOTO Step 8.2.2 to build sqlite with the thread-safe option disabled.

8.2.1) Enabling thread-safe

  • At you shell's command prompt type:
      ./configure --enable-threadsafe

8.2.2) Disabling thread-safe

  • At you shell's command prompt type:
      ./configure

8.3) Building and installing sqlite

  • cd into the directory containing the Makefile for sqlite.
  • At you shell's command prompt type:
      make
      su
      make install
      exit
  • You should make a note of which directory sqlite got installed to.

9)Building libxml

  • JXTA-C's enhanced discovery service features wild card searches.
  • As released, libxml does not provide the required support for enhanced discovery wild card searches.
  • If you are using JXTA-C 2.5.2 or prior OR JXTA-C Subversion revision #154 or prior you will need to patch Libxml for wildcard searches. Otherwise patching Libxml unnecessary.
  • If you require a patch for wildcard search support be sure to follow the instructions in section 9.2. Otherwise skip section 9.2.

9.1) Get libxml source code

  • Point your web browser to ftp://xmlsoft.org/libxml2/
  • Scroll down the page and find the source tarball you want. For example: libxml2-2.6.19.tar.gz
  • Download the tarball to your hard-drive.
  • Unpack the tarball. For example:
      $ tar -xvf libxml2-2.6.19.tar.gz
  • If you want to support wild card searches, GOTO section 9.2. Otherwise proceed to section 9.3.

9.2) Patching the source code tarball

  • Determine if you require a patch for wildcard search support for JXTA-C's enhanced discovery service.
  • The patch has been tested against libxml2-2.6.19, but should work with other versions as well.
  • From the /lib/libxml2 directory below your JXTA-C source directory (trunk or desired branch), copy the file named jxta_wildcard.diffs to the directory immediately above your libxml source directory (The directory that contains the libxml Makefile).
  • cd to the directory immediately above your libxml source directory
  • Apply the patch by typing at your shell's command prompt:
      patch -p0 -i jxta_wildcard.diffs

9.3) Building and installing libxml

  • cd into the directory containing the Makefile for libxml.
  • At you shell's command prompt type:
      chmod +x autogen.sh
      ./autogen.sh
      ./configure
      make
      su
      make install
      exit
  • You should make a note of which directory libxml got installed to.

10) Installing Expat (Not Usually Necessary, read below)

  • Expat is used indirectly by JXTA-C.
  • Expat is used directly by apr-util.
  • Expat usually comes bundled with apr-util.
  • You probably have expat already installed on your system.
  • Expat support will usually be installed as part of apr-util.
  • The information provided here is just in case you need to install expat or build the source code.

10.1) Installing Expat Binaries

10.1.1) Automatic package installer

  • Read Appendix A for more info.
  • Example of installing the latest expat and developer pack using YUM:
      $ yum install expat
      $ yum install expat-devel

10.1.2) RPM package

10.1.2.1) Auto install

  • If a dialog box pops up asking you if you want to install the RPM, click okay.

10.1.2.2) Downloading

  • Download the RPM to your system
  • To install OpenSSL using RPM, at your shell's command prompt type:
      rpm -i filename # where filename is the name of the RPM file you are installing.
  • To upgrade using RPM, at your shell's command prompt type:
      rpm -U filename # where filename is the name of the RPM file you are installing.

10.2) Building Expat from Source

10.2.1) Tarball

  • Locate the tarball of the version you are interested in building.
  • Download the tarball to your system.
  • Extract the source from the tarball. For example:
      $ tar -xvf expat-1.95.7.tar.gz

10.2.2) SRPM

  • Locate the SRPM file for the verion you are interested in installing

10.2.2.1) Auto install

  • If a dialog box pops up asking you if you want to install the RPM, click okay.

10.2.2.2) Downloading

  • Download the SRPM file to your system.
  • Extract the tarball from the SRPM. For example:
      $ rpm -i expat-1.95.7-1.src.rpm
  • Extract the source from the tarball. For example:
      $ tar -xvf expat-1.95.7.tar.gz

10.2.3) Configuring, Building, Installing

  • cd into the directory containing the Makefile for expat.
      ./configure
      make
      su
      make install
      exit
  • You should make a note of which directory expat got installed to.

11) Installing APR

  • You probably have apr already installed on your system, be sure you also have the apr developer pack "libapr-devel" installed.
  • The information provided here is just in case you need to install apr or build the source code.

11.1) Installing APR Binaries

11.1.1) Automatic package installer

  • Read Appendix A for more info.
  • Example of installing the latest apr and developer pack using YUM:
      $ yum install libapr
      $ yum install libapr-devel

11.1.2) RPM package

  • Point your web browser to http://archive.apache.org/dist/apr/binaries/
  • Locate the RPM package of interest.
  • Download the apr and apr-devel RPM files that you require to your hard-drive. For example: apr-1.2.1-1.i386.rpm and apr-devel-1.2.1-1.i386.rpm
  • cd to the directory where you downloaded the files
  • Now login as root and install the files.
  • For example at your shell's command prompt type:
      su
      rpm -i apr-1.2.1-1.i386.rpm
      rpm -i apr-devel-1.2.1-1.i386.rpm
      exit

11.2) Building APR from Source (Usually not necessary, but just in case you need to do this)

11.2.1) Tarball

  • Locate the tarball of the version you are interested in building.
  • Download the tarball to your system.
  • Extract the source from the tarball. For example:
      $ tar -xvf apr-1.2.1.tar.gz

11.2.2) SRPM

  • Locate the SRPM file for the version you are interested in installing
  • Download the SRPM file to your system.
  • Extract the tarball from the SRPM, for example:
      $rpm -i apr-1.2.1-1.src.rpm
  • Extract the source from the tarball. For example:
      $ tar -xvf apr-1.2.1.tar.gz

11.2.3) Configuring, Building, Installing

  • cd into the directory containing the Makefile for apr.
      ./configure
      make
      su
      make install
      exit
  • You should make a note of which directory apr got installed to.

12) Building apr-util

  • Members of the JXTA-C team contributed the apr_thread_pool code to apr-util project. The apr_thread_pool code was first introduced in apr-util version 1.2.7.
  • The contributed apr_thread_pool will also be included as part of the JXTA-C codebase until a future release of apr-util.
  • apr-util must be built from source because APR-Util requires a patch for SQL transaction support.
  • You have 2 options for getting apr-util:
    • GOTO section 12.1 if you want to get apr-util from the Apache Subversion repository. This version is already patched.
    • GOTO section 12.2 if you want to apply the patch yourself.

12.1) Getting the patched APR-Util source from Subversion and building

  • You can download revision 398048 from the Apache Subversion repository. This revision has been tested.
  • At your shell's command prompt type:
      svn co http://svn.apache.org/repos/asf/apr/apr-util/trunk apr-util -r 398048
  • Now at your shell's command prompt type:
      ./configure --with-apr=/location # Note: you should substitute the location of your apr installation, for example --with-apr/usr
      make
      su
      make install
      exit

12.2) Patching and building apr-util

  • A patch can be applied to the 1.2.7 release.
  • The apr-util version 1.2.7 source can be obtained from http://archive.apache.org/dist/apr/binaries/
  • Download the SRPM for your system and install the SRPM. The RPM will install a tarball.
  • Extract the files from the tarball.
  • Create an apr_dbd_fix.patch file in the root directory of apr-util.
  • Copy and paste the following patch into apr_dbd_fix.patch file.
Index: dbd/apr_dbd_sqlite3.c
===================================================================
      --- dbd/apr_dbd_sqlite3.c   (revision 392824)
      +++ dbd/apr_dbd_sqlite3.c   (working copy)
      @@ -335,7 +335,6 @@
      int nrows = 0;
      
      if (trans) {
      -        ret = dbd_sqlite3_query(trans->handle, &nrows, "END TRANSACTION;");
         if (trans->errnum) {
         trans->errnum = 0;
         ret = dbd_sqlite3_query(trans->handle, &nrows, "ROLLBACK;");
      
         *Execute the following commands to patch and build apr-util.
         patch -p0 -i apr_dbd_fix.patch
         ./configure --enable-layout=apr-util --with-apr=/location --with-sqlite3=/location # Note: you should substitute the location of your apr and sqlite installations.
         make
         su
         make install
         exit
  • You should make a note of which directory apr got installed to.

13) Building JXTA-C

13.1) Configuring, Building and Installing JXTA-C

13.1.1) Notes on the ./configure command

  • The configure command will tell the system where you have your third-party dependency libraries installed.
  • For most systems third-party dependency libraries are assumed by default to be installed in /usr unless you specify otherwise.
  • To specify a non-default directory for third-party dependency libraries you must pass the install location to the ./configure command.
  • Directory locations are specified using the --with-$XXXXX=$YYYYY option, where $XXXXX is the name of the library and $YYYYY is the install location of the library. For example ./configure --with-apr=/usr/local/apr .
  • The options you pass to ./configure depends upon which libraries you have and where they are installed.
  • The following is the list of options:
    Option Comment
    --with-apr= Specify the location of APR/APU to use.
    --with-apu= Specify the location of APU to use.
    --with-libxml2= Specify the location of libxml2 to use.
    --with-sqlite= Specify the location of SQLite to use.
    --with-openssl= Specify the location of openssl lib to use.
  • If you do not specify an option for a library, the default install location is assumed for that library.
  • If you have zlib installed and you want JXTA-C to use it, you should configure JXTA-C with the --enable-compression=no and --enable-decompression=no options. Otherwise, omit these options from the JXTA-C configure command.

13.1.2) Configure, Building and installing commands

  • cd to the directory where your JXTA-C source code resides. This is the directory containing the Makefile. Note: If you got your code from the Subversion repository and you want to compile a branch, you should cd into the directory where the branch resides instead.

  • Type the following line at your shell's command prompt:
      ./autogen

  • Since the ./configure command will depend upon the locations of your third-party libraries, the options you pass may vary (See 13.1.1). Type in the ./configure command with your options. The command below is just an example.
      ./configure --with-apu=/usr/local/apr --with-sqlite=/usr/local --with-libxml2=/usr/local

                 Note: On 64-bit machines you might need to also use the --with-pic option.
  • Now type the following at your shell's command prompt:
      make
      su
      make install
      exit
  • JXTA-C is now compiled and installed.


Appendix A) Automated Update Programs

  • Many systems have automated update programs that are built as a convenient automated front-end to package managers(RPM for example).
  • One popular automated update program is YUM (Yellowdog Updater Modified) http://linux.duke.edu/projects/yum/
  • Another popular automated update program is APT (Advanced Packaging Tool) http://www.debian.org/doc/manuals/apt-howto/
  • Automated update programs will find and install binary packages for you in one easy step.
  • Many of the libraries discussed in this document can easily be managed using an Automated Update Program.
  • Using an automated updated program will save time and steps.
  • You can use automated update programs to install any library that JXTA-C depends upon.
  • For those JXTA-C libraries that must be built from source, you probably cannot use an automated update program. Automated update programs will usually not install source code.
  • When installing/update JXTA-C dependent libraries with an automated update program you must be sure to install BOTH the base package and the developer package for the library.
  • Developer packages contain the include files that JXTA-C depends upon.
  • Be aware that using automated update programs will:
    • Require you to have administrator root priviliges.
    • Will change the configuration of your system.
    • Will impact other uses on your system.

A.1) Searching for packages

A.1.1) Search function

  • Automated update programs usually include a search function to help you search for available packages and versions. For example YUM:
      $ yum search libapr

A.1.2) Web Listings

A.2) Installing

  • Rather than get into all the specifics of using automated update programs here, it is better to read the documentation for your particular update program.
  • Some examples are presented below to give you the feel of how you might use an automated update program to get dependency libraries for JXTA-C.

A.2.1) Example: Installing the latest APR library and developer pack using YUM.

      $ yum install libapr
      $ yum install libapr-devel

A.2.2) Example: Installing a particular version of OpenSSL and developer pack using YUM.

      $ yum install openssl-0.9.8b-8
      $ yum install openssl-devel-0.9.8b-8

A.2.3) Example: Updating to a particular version of OpenSSL and developer pack using YUM.

      $ yum update openssl-0.9.8b-8
      $ yum update openssl-devel-0.9.8b-8

A.2.4) Example: Installing the latest apr, sqlite, libxml, zlib and developer packages using APT.

      $ apt-get install libapr1-dev libaprutil1-dev libsqlite3-dev libxml2-dev zlib1g-dev

Topic JxtaCLinuxBuildDoc . { Edit | Ref-By | Printable | Diffs r6 < r5 < r4 < r3 < r2 | More }
 XML java.net RSS

Revision r6 - 24 Mar 2008 - 16:17:03 - Main.vfinley
Parents: WebHome > HowToBuildJXTA-C