Boost Users :
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-06-19 08:46:52
please read my answer below.
>> extern BOOST_PROGRAM_OPTIONS_DECL __declspec(selectany)
>> std::string arg("arg");
> So, what is the *reason* for the original linker error?
To be honest I don't know what is the reason, but it sounds like a BUG
in VC7.1 linker to me. If I use default alignment in the described
scenario I can link, asap I switch to 4 byte struct member alignment
(boost libs are recompiled with that setting as well) linker can't
find the symbol. The signature of the exported symbol is exact with
the signature of looked up symbol.
May be the linker makes the look-up in Lib A and Lib B only, instead
of in program_options.lib. If I move the initialiazation to the header
with the __declspec(selectany) decl-specifier the string is indeed
present in Lib A, Lib B and program_options.lib and the linker picks
one of them.
Many thanks for your help.
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