Skip to content
quant61 edited this page Nov 25, 2021 · 14 revisions

Prerequisite

mFAST is dependent on the following tools/libraries:

Download the code either by cloning the project or getting it as a ZIP file.

To clone the project (recommended)

$ git clone --recursive  https://github.com/objectcomputing/mFAST.git

Building the code

mFAST uses CMake as its build system. CMake works on either linux or Windows with several compilers. These instructions assume GCC on Unix/Linux and Visual C++ on Windows.

On Unix/Linux systems, or when using MinGW on Windows

Follow the instruction below to compile the code.

$ cd mFAST
$ mkdir build
$ cd build
$ cmake ..
$ make

This uses the CMake out-of-source building approach to compile the code. You can also use make install to install the built library and tool into the system predefined path (/usr/local). For convenience, we will refer the build directory as $MFAST_BUILD_DIR.

The build system can be configured via -DOption=Value syntax when invoking cmake. Here are a list of commonly used configuration options applicable to mFAST.

  • CMAKE_BUILD_TYPE : Specify the building mode such as debug or release. Valid values are
    • None (default)
    • Debug
    • Release
    • RelWithDebInfo
    • MinSizeRel
  • BUILD_SHARED_LIBS : whether to build mFAST as shared/dynamic linked library. Valid values are ON and OFF with default OFF. If the value is ON, both static and shared library would be built. Notice that for application to link against mFAST shared libraries, the preprocessor macro MFAST_DYN_LINK must be defined for the application sources.
  • BOOST_ROOT : specify the root directory for your BOOST installation. If you have a problem with the build system finding your BOOST installation after specifying BOOST_ROOT, use cmake --help-module FindBoost in the command line to get further information.
  • CMAKE_INSTALL_PREFIX : specify the installation prefix for mFAST libraries and code generation tool.

To make sure mFAST will work correctly on your platform, you can run the unit test program $MFAST_BUILD_DIR/tests/mfast_test.

On Microsoft Windows

Download the CMake GUI tool to generate MSVC project files. This is normally installed automatically when you install CMake.

  • Using the Start menu, run the "CMake (cmake-gui)" program

    • Where is the source code:

      • Browse to the [MFAST_HOME] directory
    • Where to build the binaries:

      • Enter mFAST_HOME/build
        • Note: or pick another directory to contain the generated visual studio solution.
    • Click the [Configure] button.

      • If it says "Build directory does not exist, should I create it?" say "Yes"
      • When it asks "Specify the generator for this project" pick your version of visual studio.
      • You will get an "Error in configuration" message and a bunch of red in the middle box.
        • Examine the red suggested settings, adjust as necessary.
    • Click the [Add Entry] button.

      • Name: BOOST_ROOT
      • Type: Path
      • Value: the boost root directory
      • Description: Boost library path
  • Click [Configure] again.

    • There should be no errors.
  • Click [Generate]

    • This should be successful

At this point there is a visual studio solution file (mFAST.sln) in the [MFAST_HOME]\build directory. You may open it with visual studio to actually build mFAST.

The building process and unit test program require the boost DLLs; therefore make sure the BOOST DLL path is in your PATH environment variable before compiling mFAST.

Developing applications to link mFAST

Once installed, mFAST provides CMake find module to make develop mFAST application with CMake easier. Here is a basic example of CMakeLists.txt for an mFAST application.

cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(mFAST REQUIRED COMPONENTS
             coder ## needed only for FAST encoder/decoder
             json) ## needed only for JSON encoder/decoder

INCLUDE_DIRECTORIES(${MFAST_INCLUDE_DIR})
LINK_DIRECTORIES(${MFAST_LIBRARY_DIRS})

FASTTYPEGEN_TARGET(model model.xml) ## generate model.{h,inl,cpp} files from model.xml
add_executable (test ${FASTTYPEGEN_model_OUTPUTS} main.cpp)
target_link_libraries (test ${MFAST_LIBRARIES} )

If you installed the mFAST package in default system search paths, you may invoke cmake to generate Makefiles directly. If it's not in your default search paths, remember to set CMAKE_PREFIX_PATH variable correctly. Like,

$ cmake .. -DCMAKE_PREFIX_PATH=/opt