8. Development Environment Setup on Linux from source

Here are the specific steps to follow to create a development environment. Basic goals and platform-independent information are given at the beginning of each step, followed by platform-specific information.

8.1. Operating System and Basic Development Tools

To set up a development environment, you will need a web browser to download files and a C++ compiler and a version of the make utility to build the application.

Make sure you have X11 installed. This is the default in most Linux distributions. Most Linux distributions also install software development tools by default. If they are not there, update your installation with packages for C++, build tools, and SVN. You will need at least the following basic packages or their equivalents (this list comes from Ubuntu 10):

  • gcc-4.4

  • g++-4.4

  • make

  • php5-dev (only if you plan on changing xtlib and using those changes in a PHP application)

Note

This list is a rough estimate of what you need. It does not include all required dependencies.

8.2. Get and install Subversion

Most Linux distributions have packages available for installing the SVN command line tools.

If you need a graphical user interface environment for Subversion, xTuple suggests using RapidSVN. Several of our developers use it in-house, so we may be able to answer questions about it. If you decide to use RapidSVN, you will need to get that separately from http://rapidsvn.tigris.org/.

8.3. Get and install Git

Git is a version control system used by some of xTuple's development partners. You will need it to build the email integration portions of xTuple Connect.

Most Linux distributions have a git package. If yours does not, you will have to build git from source.

To build Git from sources, go to http://www.kernel.org/pub/software/scm/git/ and click on the link for a recent git-version.tar.gz to download it. Then follow the steps in the INSTALL file.

8.4. Get and install PostgreSQL

You will need header files and the libpq library to build and run OpenRPT, CSVImp, xTuple ERP, and the Updater. Point your web browser to www.postgresql.org and click on Downloads. Choose whether you are going to download a binary or source package and follow the appropriate links.

Table 1.13. PostgreSQL compatibility

xTuple ERPPostgreSQLConfiguration Parameters
FromTo
MinMaxBuilt With
 
3.03.1.0
8.08.3 
--without-openssl --prefix=/dir/where/you/want/to/install/postgresql
3.2.0at least 3.7.0
8.08.48.3.3
--with-krb5 --with-pam --with-ldap --with-openssl --with-readline --prefix=/dir/where/you/want/to/install/postgresql

Do not use the PostgreSQL packages installed by your Linux distribution's package manager. This can lead to problems when packages get automatically upgraded.

To build PostgreSQL from source, first download the source code from www.postgresql.org:

  1. Click DOWNLOADS

  2. Click SOURCE CODE

  3. Click on the desired version number

  4. Click on postgresql-version.tar.gz

  5. Click on one of the download sites near you

  6. If prompted, choose to save the file

  7. Copy the file to a location where you want to build PostgreSQL (e.g. /usr/local/src/postgres or c:\postgresql) and unpack the source files: tar xzf postgresq-version.tar.gz

Then follow the steps in the PostgreSQL documentation on installing from source code.

$ mkdir /opt/postgresql
$ cd /opt/postgresql
$ tar xzvf download-directory/postgresql-version.tar.gz
$ cd postgresql-version
$ ./configure # see table above for options
$ make
$ make check
$ su
# make install
# cd contrib/pgcrypto
# make install

  1. Build and install PostgreSQL by following the directions in the INSTALL file up through and including the gmake install step.

  2. Create a directory to hold the PostgreSQL installation.

  3. If gmake does not exist, use make instead.

  4. make check tests the binaries to make sure they work before you install them.

Tip

While you are at the PostgreSQL web site, you might want to get the pgadmin GUI client as well. After your download of the PostgreSQL source code is complete, back up your web browser two levels and then click on pgadmin3 -> release -> latest version -> os-name -> pgadmin3-version.suffix and install from this bundle.

8.5. Get Qt from Nokia

Table 1.14. Qt versions required to build various releases of xTuple ERP

xTuple ERPQtConfiguration Parameters
FromTo
  
????
4.1
-plugin-sql-psql -qt-gif -I/path/to/postgresql/include-L/path/to/postgresql/lib
2.1.02.2.1
4.2.3-shared-release-qt-sql-psql-qt-sql-odbc-qt-zlib -qt-gif -qt-libpng-qt-libjpeg -I/path/to/postgresql/include-L/path/to/postgresql/lib
2.3.03.1.0
4.3.2-shared -release -qt-sql-psql -qt-sql-odbc -qt-zlib -qt-gif -qt-libpng -qt-libjpeg -I/path/to/postgresql/include -L/path/to/postgresql/lib
3.2.03.2.2
4.4.3-plugin-sql-psql -plugin-sql-odbc -plugin-sql-sqlite -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -I/path/to/postgresql/include -L/path/to/postgresql/lib
3.3.03.5.x
4.5.1 or Qt SDK 2009.04-plugin-sql-psql -plugin-sql-odbc -plugin-sql-sqlite -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -I/path/to/postgresql/include -L/path/to/postgresql/lib
3.6.04.6.3 or Qt SDK 2010.04-plugin-sql-psql -plugin-sql-odbc -plugin-sql-sqlite -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -I/path/to/postgresql/include -L/path/to/postgresql/lib

Do not use the Qt packages installed by your Linux distribution's package manager. This can lead to problems when packages get automatically upgraded. xTuple rarely switches to new Qt versions as soon as they are available, preferring the stability of using the same Qt release for several xTuple software releases.

You can find the Qt sources at http://download.qt.nokia.com/qt/source/. Building Qt from source takes a long time, so start your Qt build when you have lots of other work to do or before leaving work for the day.

xTuple has not tried building PostBooks using Qt directly from Linux distribution installations, such as RPMs. If you try doing this then you are on your own.

$ mkdir /opt/qt
$ cd /opt/qt
$ tar xzf whereever-the-tarball-is/qt-x11-commercial-src-version.tar.gz
$ cd qt-x11-commercial-src-version
$ ./configure -prefix /opt/qt/Qt-version -v # Configuration Parameters from above
$ make
$ sudo make install

The -I and -L options are not necessary if you installed PostgreSQL in /usr.

8.6. Set your environment variables

After installing all of this software, you will probably have to change your environment variables so the build processes can find all of the right pieces. All three of the major platforms use the same variable names: PATH, INCLUDE, and LIB. The differences are in the syntax you must use to specify the values, and where you have to set them. There may also be an additional variable or two to set on particular platforms.

Note

In the following examples, environment variables are listed with spaces and newlines for readability. When you set these values, make sure you have no spaces and no newlines in your values.

Note

the following needs work to clarify what's dependent on actions taken in previous steps

PATH=/opt/bin:/opt/qt/Qt-version/bin
INCLUDE=/opt/include:/opt/qt/Qt-version/include
LD_LIBRARY_PATH=/opt/lib:/opt/qt/Qt-version/lib

8.7. Check out the OpenRPT, CSVImp, xtlib, and PostBooks source code

The source code for the xTuple projects is broken into several distinct pieces (listed in increasing order of dependency):

  • OpenRPT

  • CSVImp

  • xtlib (starting with xTuple ERP 3.7.0alpha)

  • xTuple GUI client

The source folders for these components must reside in the same folder for the compile process to succeed (not exactly true, but close enough):

<PARENT FOLDER>
+ csvimp
+ openrpt
+ xtlib
+ xtuple

Here is an example of checking out the sources using command line tools:

$ mkdir postbooks-checkout-area
$ cd postbooks-checkout-area
$ svn co https://postbooks.svn.sourceforge.net/svnroot/postbooks/xtuple/trunk xtuple
$ svn co https://openrpt.svn.sourceforge.net/svnroot/openrpt/openrpt/trunk openrpt
$ svn co https://postbooks.svn.sourceforge.net/svnroot/postbooks/csvimp/trunk csvimp
$ svn co https://poostbooks.svn.sourceforge.net/svnroot/postbooks/xtlib/trunk xtlib

Here is an example using RapidSVN on Windows. It places the source files in C:\Qt\xTuple-src.

  1. Start RapidSVN.

  2. In RapidSVN click REPOSITORY - CHECKOUT. Enter the URL and destination directory. Do this four times with the following URL/Directory combinations:

    https://openrpt.svn.sourceforge.net/svnroot/openrpt/openrpt/trunk C:\Qt\xTuple-src\openrpt
    https://postbooks.svn.sourceforge.net/svnroot/postbooks/xtuple/trunk C:\Qt\xTuple-src\xtuple 
    https://postbooks.svn.sourceforge.net/svnroot/postbooks/csvimp/trunk C:\Qt\xTuple-src\csvimp
    https://postbooks.svn.sourceforge.net/svnroot/postbooks/xtlib/trunk C:\Qt\xTuple-src\xtlib

    Accept a security key for each host when you connect. Once the sources are downloaded, you can close RapidSVN.

8.8. Build OpenRPT

Next build OpenRPT:

$ cd OpenRPT-checkout-dir
$ qmake
$ make

If make does not exist in your Linux environment, try gmake instead.

When the build is complete, verify that OpenRPT works. Go to your OpenRPT-checkout-dir/bin and run OpenRPT.exe (or openrpt on Linux or openrpt.app on Mac). Select DATABASE - CONNECT TO DATABASE from the program's menu. Click the OPTIONS button and enter your database information. If the PostgreSQL driver does not appear in the list, then it has failed to load probably because of some missing dependencies. See the troubleshooting section below for help resolving these dependency problems. Make sure that you can connect to your database before continuing.

8.9. Build CSVImp

Next build CSVImp. Follow exactly the same steps as for OpenRPT, only change to the CSVImp checkout directory first.

8.10. Build xtlib

To build xtlib, follow exactly the same steps as for OpenRPT, only change to the checkout-dir/xtlib/src directory first.

8.11. Build the main xTuple application

$ cd checkout-dir/xtuple
$ qmake
$ make

The same platform-specific qualifiers apply as when building OpenRPT.

If you want to distribute your compiled xTuple ERP binaries to other machines, you'll need to bundle the necessary shared libraries and distribute the whole collection.

Distribution on Linux is not documented yet.

8.11.1. Including CSVImp

You can use the CSV import tool from the main xTuple application starting with xTuple ERP 3.5.1. If you want to do so, copy the plugin library to the right location. Assuming the xtuple, openrpt, and csvimp directories are next to each other, here are the steps:

$ mkdir bin/xtuple/plugins
$ cp ../csvimp/plugins/libcsvimpplugin.so bin/xtuple/plugins