Geeks With Blogs
Tex-blog Mobile and other stuff
I spent today some time integrating program_options boost library, since I encountered some difficulties I would like to share my experiences.

Firstly, I compile my project with Microsoft Visual Studio 2008. Project is build with UNICODE enabled and also I use stlport 5.2. program_options library requires you to compile lib files in order to use it, it is not enough to just include headers. You could download libs from, but as to my knowledge they do not provide versions compiled with stlport. What's left is to compile libs on our own.

'Getting started' document that can be found on boost site contains all information required to compile libs in a standard way. Libs are being build using internal tool called bjam. In just mentioned document it is stated that binary versions of this tool are available, but I could not find it - but building this tool is really easy.

Next step is to modify user-config.jam - found in BOOST_ROOT\tools\build\v2. We want boost to use stlport, to do that uncomment and update following line:

using stlport : : C:/Libs/STLport-5.2.0/stlport C:/Libs/STLport-5.2.0/lib ;

Since I enable streams in stlport I also use stlport libs. Actually this configuration setting was the major problem that gave me a little headache. I was constanly getting linker errors in my application, looking slightlly like that:

error LNK2019: unresolved external symbol "public: __thiscall boost::program_options::options_description::options_description(class stlpd_std::basic_string<char,class stlpd_std::char_traits<char>,class stlpd_std::allocator<char> > const &,unsigned int)" (??0options_description@program_options@boost@@QAE@ABV?$basic_string@DV?$char_traits@D@stlpd_std@@V?$allocator@D@2@@stlpd_std@@I@Z) referenced in function _main

The reason was that boost was still compiling libs with microsoft stl. So the problem was with the paths in user-config.jam. If you are encountering it, rename temporarily microsoft's string stl header file to some other name (suggestion was found somwhere on internet), and check if boost build faild, if so then this means that stlport paths are incorrect.

Once we have bjam.exe in our path, we start Visual Studio 2008 Command Prompt. This way we have all path to compiler and linker alredy setup. Then we go to BOOST_ROOT folder and invoke build command.

Now to actual build command, below is what I have found to work for me, I put this in batch file and execute in BOOST_ROOT directory:

set BOOST_PROJ=--with-program_options
set BOOST_ROOT=c:\libs\boost_1_37_0
set INSTALL_DIR=c:\libs\Boost

set BUILD_DIR=%BOOST_ROOT%\build-boost
rem use -d2 to see more details
set BJAM_OPTS=-q -a -d0
set BJAM_CONF=--build-dir=%BUILD_DIR% --toolset=msvc --build-type=complete install --prefix=%INSTALL_DIR%
set CL_OPTS=stdlib=stlport link=static cxxflags="-Zc:wchar_t" %BOOST_PROJ%


rd /S /Q %BUILD_DIR%
Libraries will be placed in INSTALL_DIR\lib folder.

And thats all. Posted on Sunday, November 23, 2008 7:03 PM C++ | Back to top

Comments on this post: My experiences with boost::program_options configuration

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Martinez | Powered by: