Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-06-18 12:47:31


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");

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 + ")";
        } else {
            return arg;
        }
    }

On Wed, Jun 18, 2008 at 3:47 PM, Ovanes Markarian
<om_boost_at_[hidden]> wrote:
>
> Hi *!
>
> We switched the alignment of boost (1.34.0 + VC 7.1) libs to 4 byte, since our project has a restriction of 4byte struct member alignment and we receive a linker error that program_options can no link to a boost::program_options::arg string global.
>
> error LNK2001: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const boost::program_options::arg" (?arg_at_program_options_at_boost@@3V?$basic_string_at_DU?$char_traits_at_D@std@@V?$allocator_at_D@2@@std@@B)
>
>
> Making the dumpbin /exports from the boost_program_options....lib I clearly find this symbol as exported one, with the exactly searched signature. Using the default struct member alignment I can link to the program_options lib whithout any problems. Any ideas or suggestions are really welcome!
>
>
>
> With Kind Regards,
> Ovanes


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net