Boost logo

Boost Users :

From: Yongwei Wu (wuyongwei_at_[hidden])
Date: 2007-09-18 23:10:47


On 19/09/2007, Yongwei Wu wrote:
> Hi all,
>
> I read about the following discussion when I encountered a similar
> issue (using -MTd -D_STLP_DEBUG=1 on the command line) and googled:
>
> John Maddock wrote:
> > Jason Ivey wrote:
> > > 1>LINK : fatal error LNK1104: cannot open file
> > > 'stlportstld_x.5.1.lib'
> > >
> > > The problem is that all of the stlport libraries are named
> > > stlportstld.5.1.lib or similar. I did try to just rename the
> > > library to make it match but, of course, I got a boat load of
> > > unresolved external linker errors pointing to names such as
> > > "stlpdx_std::basic_string." Looking at a dumpbin output of the
> > > actual regex library it is linking against,
> > > libboost_regex-vc80-mt-sgdp-1_34_1.lib, I found linker directives of
> > > the form:
> >
> > Not sure, but I believe the debug versions of Boost lib's built against
> > STLPort are built with __STL_DEBUG defined, so you will need to do likewise
> > when building your application. Also don't forget that Boost.Regex is "Just
> > a bunch of sources" so you could turn auto-linking off (define
> > BOOST_REGEX_NO_LIB or BOOST_ALL_NO_LIB) and link against your own build of
> > the regex sources (just build all of libs/regex/src/*.cpp into a static
> > lib).
>
> It seems to me the reason for the failure is that there are some
> DLL-related conflicts. In _detect_dll_or_lib.h:
>
> # if defined (_STLP_RUNTIME_DLL)
> # if !defined (_STLP_USE_STATIC_LIB)
> # if !defined (_STLP_USE_DYNAMIC_LIB)
> # define _STLP_USE_DYNAMIC_LIB
> # endif
> # else
> /* The user is forcing use of STLport as a dynamic library. We signal
> * it so that the STLport namespace will be modify to report such a
> * combination and force the user to link with the rebuilt STLport
> * library.
> */
> # define _STLP_USING_CROSS_NATIVE_RUNTIME_LIB
> # endif
> # else
> # if !defined(_STLP_USE_DYNAMIC_LIB)
> # if !defined (_STLP_USE_STATIC_LIB)
> # define _STLP_USE_STATIC_LIB
> # endif
> # else
> /* Idem previous remark but the user forces use of the static native
> * runtime.
> */
> # define _STLP_USING_CROSS_NATIVE_RUNTIME_LIB
> # endif
> # endif
>
> Is it possible that such a conflict exists when
> libboost_regex-vc71-mt-sgdp-1_34_1.lib (my case) or
> libboost_regex-vc80-mt-sgdp-1_34_1.lib (OP's case) is being built?

After testing with STLport 4.6.2, I am more inclined to believe this
is the reason. When I built the same simple program with STLport
4.6.2 again (with /MTd /D_STL_DEBUG=1), I saw these messages (with
/link /verbose):

Starting pass 1
Processed /DEFAULTLIB:stlport_vc71_stldebug_static.lib
Processed /DEFAULTLIB:libcpmtd
Processed /DEFAULTLIB:libboost_regex-vc71-mt-sgdp-1_34_1.lib
...
        Loaded libboost_regex-vc71-mt-sgdp-1_34_1.lib(instances.obj)
Processed /DEFAULTLIB:stlport_vc71_stldebug.lib
    Searching C:\Libraries\STLport-4.6.2\lib\stlport_vc71_stldebug.lib:
      Found "__declspec(dllimport) public: __thiscall
_STL::basic_string<char,class _STL::char_traits<char>,class
_STL::allocator<char> >::~basic_string<char,class
_STL::char_traits<char>,class _STL::allocator<char> >(void)"
(__imp_??1?$basic_string_at_DV?$char_traits_at_D@_STL@@V?$allocator_at_D@2@@_STL@@QAE_at_XZ)
        Referenced in libboost_regex-vc71-mt-sgdp-1_34_1.lib(instances.obj)
        Referenced in libboost_regex-vc71-mt-sgdp-1_34_1.lib(regex.obj)
        Referenced in
libboost_regex-vc71-mt-sgdp-1_34_1.lib(w32_regex_traits.obj)
        Loaded stlport_vc71_stldebug.lib(stlport_vc71_stldebug46.dll)
stlport_vc71_stldebug.lib(stlport_vc71_stldebug46.dll) : error
LNK2005: "public: __thiscall _STL::basic_string<char,class
_STL::char_traits<char>,class _STL::allocator<char>
>::~basic_string<char,class _STL::char_traits<char>,class
_STL::allocator<char> >(void)"
(??1?$basic_string_at_DV?$char_traits_at_D@_STL@@V?$allocator_at_D@2@@_STL@@QAE_at_XZ)
already defined in test.obj
...

I see no reason why the DLL build of STLport (stlport_vc71_stldebug.
lib) should be referenced in a static build of Boost.Regex
(libboost_regex-vc71-mt-sgdp-1_34_1.lib).

I am not familiar with bjam enough to investigate further. Any help
is appreciated.

Best regards,

Yongwei

-- 
Wu Yongwei
URL: http://wyw.dcweb.cn/

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