KDb/Build: Difference between revisions

From KDE Community Wiki
< KDb
Line 35: Line 35:
*Enable [[#Enabling_tests|tests]] (BUILD_TESTING)
*Enable [[#Enabling_tests|tests]] (BUILD_TESTING)
*Speed up [[#Speed_up_the_build|linking on Linux]] (CMAKE_C_FLAGS, CMAKE_CXX_FLAGS)
*Speed up [[#Speed_up_the_build|linking on Linux]] (CMAKE_C_FLAGS, CMAKE_CXX_FLAGS)
You can also alter these options once you configure the build by invoking:
ccmake .
in <tt>{predicate-build-dir}</tt>, then to reconfigure press <tt>c</tt> key when you're done and then press <tt>q</tt> key.


Read about more cmake options [http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Options here].
Read about more cmake options [http://www.cmake.org/cmake/help/v2.8.8/cmake.html#section_Options here].
{{Note|TODO: explain PREDICATE_DEBUG_GUI, PREDICATE_EXPRESSION_DEBUG}}


===Option 2: Configuration for local installation===
===Option 2: Configuration for local installation===

Revision as of 11:08, 9 October 2014

Template:ForDevelopers

Requirements

Required software components

  • C++ compiler, e.g. gcc
  • Qt 4.7.0 or newer (both libraries and development files/tools)
  • SQLite 3.6.16 or newer (both the library and development files)

Optional components

  • libpq 7.3 or newer for PostgreSQL support (both the access library and development files)

Note

PostgreSQL Server installation is not needed for building Predicate or software that uses Predicate. The server is needed only for running the actual database service. Any installation on separate (e.g. remote) machine can be reused.


  • libmysqlclient (both the access library and development files) for MySQL support

Note

MySQL Server installation is not needed for building Predicate or software that uses Predicate. The server is needed only for running the actual database service. Any installaton on separate (e.g. remote) machine can be reused.


Get the source code

Download Predicate source code as explained on the Download page. The root directory of the source code is referred as {predicate-source-dir}, and the root build directory is referred as {predicate-build-dir}.

Configuration

Option 1: Configuration for global installation

If you want to have Predicate installed in the global PREFIX, type:

mkdir {predicate-build-dir}
cd {predicate-build-dir}
cmake {options} {predicate-source-dir}

This will configure installation of Predicate libraries into /usr/local/lib, its binaries into /usr/local/bin, etc.

To change that to /usr/lib, etc., change the cmake command to:

cmake -DCMAKE_INSTALL_PREFIX=/usr {options} {predicate-source-dir}

cmake options

{options} are extra cmake options that let you to:

You can also alter these options once you configure the build by invoking:

ccmake .

in {predicate-build-dir}, then to reconfigure press c key when you're done and then press q key.

Read about more cmake options here.

Note

TODO: explain PREDICATE_DEBUG_GUI, PREDICATE_EXPRESSION_DEBUG


Option 2: Configuration for local installation

To void installing to global location like /usr, for whatever reason, for your convenience, config-for-local.sh script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:

1. Make sure $PREDICATE_INSTALL_PREFIX environment variable is set to directory that is indended PREFIX for the local Predicate installation, e.g. $HOME/predicate/inst.

2. Then:

mkdir -p {predicate-build-dir}
cd {predicate-build-dir}

(better pick your {predicate-build-dir} outside of the source code)

{predicate-source-dir}/tools/config-for-local.sh

Note that to have the Predicate installation work environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Double check this:

_libdir=lib # or lib64 for 64-bit platforms
export PATH=$PREDICATE_INSTALL_PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir/pkgconfig:$PKG_CONFIG_PATH
export QT_PLUGIN_PATH=$PREDICATE_INSTALL_PREFIX/$_libdir/plugins/predicate:$QT_PLUGIN_PATH

Option 3: Configuration for re-using local KDE 4 installation

If you use local KDE 4 installation, e.g. for developed applications, for your convenience, config-for-kde.sh script has been prepared with default configuration settings. You can find it in tools/ subdirectory of the source code. Use it as follows:

First make sure $KDEDIRS environment variable is set to directory that is intended PREFIX for the local KDE 4 installation, e.g. $HOME/kde4/inst. Then:

mkdir -p {predicate-build-dir}
cd {predicate-build-dir}

(better pick your {predicate-build-dir} outside of the source code)

{predicate-source-dir}/tools/config-for-kde.sh

Note that to make the Predicate installation work, environment variables PATH, LD_LIBRARY_PATH, PKG_CONFIG_PATH, QT_PLUGIN_PATH should be set properly. Several of these are probably already set for the local KDE 4 installation but better double check this:

_libdir=lib # or lib64 for 64-bit platforms
export PATH=$KDEDIRS/bin:$PATH
export LD_LIBRARY_PATH=$KDEDIRS/$_libdir:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$KDEDIRS/$_libdir/pkgconfig:$PKG_CONFIG_PATH
export QT_PLUGIN_PATH=$KDEDIRS/$_libdir/kde4/plugins:$QT_PLUGIN_PATH

Debugging options

Recommended for accurate debugging: The default debug setting is RelWithDebInfo which is suitable only for obtaining backtraces. If you are developing code that uses Predicate or developing Predicate itself you may want to precisely set breakpoints, watch points, use step by step command accurately in your debugger, rely on assertions, debug and warning messages. If this is the case, you can replace -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake option with:

-DCMAKE_BUILD_TYPE=DebugFull

Using DebugFull results in a slower code. That can be acceptable in most cases during testing and development given the machine is fast enough. It is not intended for production releases of the software unless you know what you're doing.

Enabling tests

To build with tests enabled (both unit tests and functional tests), add -DBUILD_TESTING=ON to the cmake command before building.

Build

For any configuration option: Type the above configuration command only once, to configure the cmake-based buildsystem. Then just type:

 make
 make install

Speed up the build

Recommended: Taking advantage of multi-core processors. On dual-core machines compilation can be greatly speed up with the -j parameter of the make program. For example whenever you are invoking make, for dual-core processor try to invoke:

make -j3

Similarly, for quad-core processor:

make -j5

Generaly for N-core processor use the -jN+1 parameter.

Recommended: Faster linking on Linux. Linking can take noticeable time in large software such as Calligra. On Linux Gold linker can be used to speed up this task. If you're building for Linux, install the Gold linker package and add the following to your cmake command:

-DCMAKE_C_FLAGS=-fuse-linker-plugin -DCMAKE_CXX_FLAGS=-fuse-linker-plugin

(you can set the CMAKE_C_FLAGS adn CMAKE_CXX_FLAGS variables in your {build dir}/CMakeCache.txt file either using text editor or the ccmake tool)

Notes

To enable debugging inside of bison (.y) file, put this in your $HOME/.gdbinit config file:

set directories ~/dev/src/predicate/Predicate/parser