$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2008-06-19 01:11:19
Ovanes Markarian wrote:
> Sorry for the double post. I had to patch Source of the Program
> Options to solve this issue. Here the organization of the project
> which produced Linking errors:
> 
> 
>                    BoostProgramOptions.LIB (we link against DLL version of LIB)
>                                   ^
>                                   |
>                          Lib with PO retriever (static lib)
>                                   ^
>                                   |
>  +------------------------------------------------------------+
>   |                                                             |
> Lib A                                                     Lib B
>   ^                                                            ^
>   |                                                             |
>  +------------------------------------------------------------+
>                                ^
>                                |
>             DLL which links with A & B
> 
> Lib A & Lib B rely on the same program options reader.
> 
> 
> Initial problem was as described below. To solve this issue I had to
> remove the arg definition in the value_semantic.cpp file and
> initialize it in the header file detail/value_semantic.hpp with MS
> specific __declspec(selectany) which causes to ignore multiple defined
> linker symbol. Here the linke in the value_semantic.hpp
> 
>     extern BOOST_PROGRAM_OPTIONS_DECL __declspec(selectany)
> std::string arg("arg");
So, what is the *reason* for the original linker error?
> 
> I hope you can reproduce this behaviour and apply this patch to next
> boost destributions.
> 
> 
> With Kind Regards,
> Ovanes
> 
> 
> P.S. I don't know if the entire fix is worth doing it when the arg's
> value is copied in the source anyway. Just a small example:
> 
> template<class T, class charT>
>     std::string
>     typed_value<T, charT>::name() const
>     {
>         if (!m_default_value.empty() && !m_default_value_as_text.empty()) {
>             return arg + " (=" + m_default_value_as_text + ")";
Well, this will rely on compiler/linker ability to merge duplicate strings.
- Volodya