Boost C++ Libraries Home Libraries People FAQ More


Chapter 1. Boost.Application

Renato Forti

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

Table of Contents

Design overview
Suported Application Types
Common Application
Server Application
Application Roadmap
Application Context
Application Apects
Using Application Handlers
Handling errors
Throws an 'system_error' version.
Set 'error_code' on error version.
Common Application
Server Application
Customize Aspects
Customize Signals/Handlers
Other Features
Single Instance Feature
Extending Application (Plugin System)
Windows specifics
Setup for Windows Service
POSIX specifics
Is Boost.Application thread-safe?
How Unicode (Windows) is hadled?
Can I customize a application SIGNALS?
Can I customize a library provided aspects?
Can I build another aspects to application?
Can I build another application mode? What is needed?
I have found a bug, how do I notify?
Supported compilers and platforms
Core Reference
Application Modes Reference
Aspects Reference
Shared Library Reference
TODO/Future Releases
Future Releases
Revision History
[Caution] Caution

This is not yet an official Boost C++ library. It wasn't reviewed and can't be downloaded from This beta is available to boost community to know real interest and get comments for refinement.The intention is to submit library to formal review, if community think that it is interesting!

Sometimes we need run application for long time (e.g. Server Application), we need a mechanism to extend this application on runtime, and we need some facilities to access paths, ensure single instance instantiation on system, manage and catch signals and so on.

This work is recurrent each time that we need build and deploy an application for particular system, and the way to do this, change a lot on each of these systems.

For instance on Windows side we have 'services' and on Unix (POSIX) side we have 'daemons' that are used to build long-running executable applications (e.g. server) and these two APIs have no similarity. Thus, in this scenarios, is so much difficult to developer have your application running on Windows or on POSIX as server without a lot of work. The work is harder if we need run same application in both systems.

Other problem raise when user want provide a way to extend your application using a plug-in mechanism. Like Service/Daemon, the shared modules (DSO) manipulation changes a lot on Windows and POSIX.

Obtain simple thing like paths, arguments, manipulate signal, can be annoying, since it also don't has a common interface to do this on both systems.

Boost.Application library aims to make significantly easier for the developer has your application runs in cross-platform (POSIX/Windows) environment. Boost.Application provides a application environment, or start point to any people that want a basic infrastructure to build an system application on Windows or Unix Variants (e.g. Solaris, Linux, MacOS).

The Boost.Application uses behaviours modeled using 'aspects' concept proposed by 'Vicente J. Botet Escriba', that allow easy extension and customization of library components. The application modes uses these components internally to achieve the user desirable behaviours.

Boost.Application provide many usefull ready-to-use features, e.g:

  • Run application as Windows Service;
  • Run application as UNIX/POSIX Daemon;
  • Plugin extension system;
  • Process(executable) Single instance Instantiation support;
  • Application SIGNAL/Callbacks customization;
  • And many others.

Here's a simple example of how to construct a application with Boost.Application:

#include <iostream>
#include <boost/application.hpp>

using namespace boost;

1class myapp

   2int operator()(application::context& context)

      3boost::shared_ptr<application::args> myargs
         = context.find<application::args>();

      if (myargs)
         std::vector<std::string> arg_vector = myargs->arg_vector();

         // only print args on screen
         for(std::vector<std::string>::iterator it = arg_vector.begin();
            it != arg_vector.end(); ++it) {
            std::cout << *it << std::endl;

      4// code your application

      return 0;

// main

int main(int argc, char *argv[])
   5myapp app;

   6application::context app_context;

      boost::make_shared<application::args>(argc, argv));

   8return application::launch<application::common>(app, app_context);


Define application functor class


Define the application operator that will receive a application context


Make use of an'aspect'


Add other application logic


Instantiate your application


Create a context application aspect pool


Add an aspect for future use. An 'aspect' can be customized, or new aspects can be created


Start the application on the desired mode (common, server)

Refer to "road map" to know all required/optional steps to build a complete application using Boost.Application. To high level design overview, refer to '"design overview"'

[Caution] Caution

This documentatuion is in "Work in Progress" status. DOWNLOAD THE LIB

Last revised: April 15, 2014 at 17:35:10 GMT