3

I was under the impression that the boost bcp, with the namespace option, was meant to rename the includes and defines for any listed modules. Upon running the tool and examining the output, it doesn't seem to do that. How am I to redistribute these if they still #include <boost/*> and expect the end-user's #include <boost/*> not to cause a version conflict? Does it just wrap these with namespace closures?

I used the following bcp command:

.\boost_1_53_0\dist\bin\bcp.exe --boost=boost_1_53_0 --namespace=myboost --namespace-alias smart_ptr filesystem array.hpp container move ptr_container algorithm/string.hpp tokenizer.hpp thread chrono atomic foreach.hpp build myboost

A quick grep of a file yeilds:

[boost]grep -e "boost/" algorithm\string.hpp
grep -e "boost/" algorithm\string.hpp
#include <boost/algorithm/string/std_containers_traits.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/find.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/erase.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/find_iterator.hpp>

I am pretty certain that this is the use case for the bcp tool with the namespace options, however, I'm clearly misunderstanding some common C++ concept/usage, right? Or, perhaps, I am using the tool incorrectly?

Thanks in advance for any insight.

kevinmm
  • 3,136
  • 4
  • 21
  • 24
  • 1
    To add to this, my colleague is adamant that we must search and replace "boost" in all includes and defines. Yet, posts, such as this [one](http://stackoverflow.com/questions/836875/creating-library-with-backward-compatible-abi-that-uses-boost), indicate that bcp already does this!!!??? – kevinmm Jun 14 '13 at 05:56
  • 1
    Just to clarify, I do understand that the main focus of the tool is to scan the boost modules for dependencies and copy them to the output path. I am primarily concerned with the --namespace and --namespace-alias options, and what additional functionality that they provide. – kevinmm Jun 14 '13 at 06:00

2 Answers2

3

bcp --namespace=myboost --namespace-alias regex config build /foo

Copies the full regex lib (in libs/regex) plus the config lib (libs/config) and the build system (tools/build) to /foo including all the dependencies. Also renames the boost namespace to myboost and changes the filenames of binary libraries to begin with the prefix "myboost" rather than "boost". The --namespace-alias option makes namespace boost an alias of the new name.

Only binaries will be renamed (libboost_regex.so will be libmyboost_regex.so), not header files. Also, namespace boost will be replaced with myboost (and boost will be alias to myboost).

ForEveR
  • 55,233
  • 2
  • 119
  • 133
  • 1
    So... no way then to avoid version conflicts in the #include statements with BCP? I'm running into the same issue. Sure, the namespace is renamed, but any other code that uses boost will pick up my copy of the headers whenever they are present. – flodin Aug 16 '14 at 09:47
0

Like the name says, it renames the namespace and the library files (i.e. .dlls and .libs), but not the directories in wich the headers reside, and therefore not the includes.

The Boost libraries normally reside in namespace boost. With bcp you changed that namespace to myboost. So for example this code becomes valid:

#include <boost/sharedptr.hpp> //header directories haven't changed

myboost::shared_ptr<int> pi = myboost::make_shared<int>(5); //but the namespace has

Thanks to --namespace-alias you can continue to use namesapce boost, since boost has become an alias for myboost:

boost::shared_ptr<int> pi; //ok, this is in fact a myboost::shared_ptr

See the examples in the documentation: http://www.boost.org/doc/libs/1_53_0/tools/bcp/doc/html/index.html

Arne Mertz
  • 24,171
  • 3
  • 51
  • 90