Boost logo

Boost-Build :

Subject: [Boost-build] How to avoid already defined symbols with shared linkage using some libraries as static?
From: Dmitry Timoshenko (dimentiy2k_at_[hidden])
Date: 2011-04-02 09:56:56


I have two libraries: first (1) & second (2). The 2nd depends on 1st.
The 1st library is only built as static (no dll, small library), but 2nd
can also be built as shared object.
1st library also have dependensies on boost e.g. on boost_date_time

How can I make bjam always use static boost libraries not depending on
target's link feature?

The problem occurs in link=shared configruation.
The 2nd refers to 1st that always compiled as static.
Boost libraries that 1st depends on in this case also compiled as
static, but linker when tries to link 2nd as shared (dll) searches for
boost compiled as dll.
Such as if boost compiled as dll is not found I get the not found error.
But if it's found (Due to if I put references to necessary boost
libraries into 2nd's bjam project and libraries get compiled into dll
aslo in this case)
I get the symbol already defined linker error, due to it's defined by
both found (just compiled) dll and 1st static library's boost dependencies.

1st build options: toolset=msvc variant=debug,release link=static
threading=multi runtime-link=shared
2nd build options: toolset=msvc variant=debug link=shared
threading=multi runtime-link=shared

Below the more detailed description.

The definition of one of the 1st library targets look like:

### smart timers
lib smart_timers
         : timers.cpp # sources

         : <link>static # requirements

The 2nd library refers to smart_timers. So when I refers in bjam 2nd's
library project definition only <libarary>smart_timers. I get the
boost_date_time properly compiled into static lib, due to smart_timers
(1st lib) refers it within static configuration. Then when the 2nd
library is being compiled
I get the error:
LINK : fatal error LNK1104: cannot open file
'boost_date_time-vc80-mt-gd-1_41.lib' due to linker looks for the
because of 2nd library is compiled with link=shared option.
tries to find data_time.dll, but dll doesn't exists.

When I refers to <library>/boost/date_time//boost_date_time directly
from 2nd's library bjam project. I get the symbol already defined due to
it is
'contained/refered' by smart_timers statically built with static

libsmart_timers-vc80-debug-1_00.lib(timers.obj) : error LNK2005: 
"public: __thiscall boost::gregorian::greg_month::greg_month(unsi
gned short)" (??0greg_month_at_gregorian@boost@@QAE_at_G@Z) already defined in 
Please, could anyone help me, how to resolve this? I also need no to 
build 1st as shared, I need it to be static.
Thank you.

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at