Chapter 8. Using the library

Table of Contents

8.1. Building (and testing) the library
8.1.1. Building on Mac OS X
8.1.2. Building on Windows
8.1.3. Building on POSIX systems
8.2. Linking with the library
8.2.1. Linking on Mac OS X
8.2.2. Linking on Windows
8.2.3. Linking on POSIX

8.1. Building (and testing) the library

Please see the requirements chapter to find out what the required files are.

8.1.1. Building on Mac OS X

  1. Download the necessary third party libraries such as SQLite3 and, if needed, a type traits library such as Loki or boost. Build and install the libraries. See "Source file organisation" for an example of a development machine setup.

  2. Open the <distribution-root-directory>/proj_mac/ccs_serialization.xcodeproj project file for Xcode 2.4.

  3. Set up the paths to the third party library source/header files in the project settings. If your development machine has a source file organisation similar to the one shown above, then the project file will probably not require changing, otherwise you will need to change the 'Header Search Paths' setting in the 'build' tab of the 'ccs_serialization' info window. You may also need to change the paths to the SQLite3 source file by changing the relative path of the 'sqlite3' group that the source/header files are in (in the Xcode project).

  4. Modify the config.hpp file so that the library will know which third party libraries you have installed. The section to edit looks like this:

    // begin user/client settable defaults
    
    // If you wish to enable the support of a library then set the value to one;
    // if you wish to explicitly disable the support of a library because, for example,
    // you don't have it or don't want to use it, then set the value to zero.
    
    #if !defined(HAVE_LOKI_LIBRARY)
      #define HAVE_LOKI_LIBRARY 1
    #endif
    
    #if !defined(HAVE_BOOST_LIBRARY)
      #define HAVE_BOOST_LIBRARY 1
    #endif
    
    #if !defined(HAVE_TBB_LIBRARY)
      #define HAVE_TBB_LIBRARY 1
    #endif
    
    // end user/client settable defaults
  5. Decide on whether you want to use the static library or dynamic library versions of the library, and build the appropriate versions. For a static library, build the 'sqlite3_static' and 'serialization_static' targets; for a dynamic library, build the 'sqlite_dynamic' and 'serialization_dynamic' targets. You should now have the built libraries which can then be used by your C++ program. If the compiler complains about not finding source files, check your settings carefully.

  6. It is recommended that you build and run the tests to verify that the library is functioning correctly under your development environment. You do this by building the 'unitTestsStatic' target (if you elected to use the static library version) or the 'unitTestsDynamic' target (if you elected to use the dynamic library version). After building the test executable, the test rig will run it and compare its output with the expected output which are in the /test/cross_platform_output_XXX.txt files. The success or failure will be shown in Xcode's build output window (you will need to show the build transcript to see the details if the test fails).

8.1.2. Building on Windows

  1. Download the necessary third party libraries such as SQLite3 and, if needed, a type traits library such as Loki or boost. Build and install the libraries. See "Source file organisation" for an example of a development machine setup.

  2. Open the <distribution-root-directory>/proj_win/ccs_serialization.vc8.sln solution file for Visual C++ 2005 or the <distribution-root-directory>/proj_win/ccs_serialization.vc9.sln solution file for Visual C++ 2008.

  3. Set up the file paths to the third party library source/header files in the project settings. If your development machine has a source file organisation similar to the one shown above, then the project file will probably not require changing, otherwise you will need to change the Additional Include Directories setting in the C/C++ section of the ccs_serialization properties dialog. You may also need to change the paths to the SQLite3 source file by changing the relative path of the files in the 'sqlite3' folder (in the VC++ project).

  4. Modify the config.hpp file so that the library will know which third party libraries you have installed. The section to edit looks like this:

    // begin user/client settable defaults
    
    // If you wish to enable the support of a library then set the value to one;
    // if you wish to explicitly disable the support of a library because, for example,
    // you don't have it or don't want to use it, then set the value to zero.
    
    #if !defined(HAVE_LOKI_LIBRARY)
      #define HAVE_LOKI_LIBRARY 1
    #endif
    
    #if !defined(HAVE_BOOST_LIBRARY)
      #define HAVE_BOOST_LIBRARY 1
    #endif
    
    #if !defined(HAVE_TBB_LIBRARY)
      #define HAVE_TBB_LIBRARY 1
    #endif
    
    // end user/client settable defaults
  5. Decide on whether you want to use the static library or dynamic library versions of the library, and build the appropriate versions. For a static library, build the 'DebugStatic' and 'ReleaseStatic' configurations; for a dynamic library, build the 'DebugDynamic' and 'ReleaseDynamic' configurations. You should now have the built libraries which can then be used by your C++ program. If the compiler complains about not finding source files, check your settings and file paths carefully.

  6. It is recommended that you build and run the tests to verify that the library is functioning correctly under your development environment. You do this by building the 'unitTests' project with any or all configurations such as 'DebugDynamic', 'DebugStatic', etc. When you select the Build command, Visual C++ will compile and link the test program, then execute it, and then compare its output with the expected output which are in the /test/cross_platform_output_XXX.txt files. You should see a message in the Output window indicating success or failure.

8.1.3. Building on POSIX systems

  1. Download the necessary third party libraries such as SQLite3 and, if needed, a type traits library such as Loki or boost. Build and install the libraries. See "Source file organisation" for an example of a development machine setup.

  2. If you prefer to keep the object files in a separate directory (to avoid cluttering up the top level directory), create a directory for the object files, for example, a build directory in the top level of the distribution, and then perform a 'cd <distribution-root-directory>/build' from a shell.

  3. Configure the library. For example, the library expects to be able to #include "sqlite3.h" so the path to the SQLite3 header files must be set up on the command line for the C++ compiler. When you have set up your configuration, create the Makefile and config.h files by performing a './configure' from a shell (or '../configure' if you used a build directory).

  4. Build the library by performing a 'make' from a shell.

  5. It is recommended that you build and run the tests to verify that the library is functioning correctly under your development environment. You do this by performing a 'make check' from a shell. After building the test executable, the 'check' target will run it and compare its output with the expected output which are in the /test/cross_platform_output_XXX.txt files. The success or failure will be shown in the shell.