
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
std::string typed_value ::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