[C++-sig] boost.python multiply defined symbols

David Abrahams dave at boost-consulting.com
Wed Dec 13 16:47:07 CET 2006

John Reid <j.reid at mail.cryst.bbk.ac.uk> writes:

> Hi,
> When I create a static library that uses boost.python 
> and subsequently link this into an extension some boost.python
> functions are multiply defined.
> I've attached a minimal test case that shows this problem. The output
> from bjam --v2 -q is in the file bjam.out.
> Is there some way to tell msvc 8 not to include the inlined boost.python
> functions in the static library? 

I don't know.  Near as I can tell, what you're seeing is a compiler
bug.  An inline function should never cause this sort of link error.
A member function of a class template should also never cause it.  So
an inline member function of a class template *really* shouldn't cause
it :)

> Or should this be fixed in the boost.python code?

To the best of my knowledge, there isn't a flaw in the Boost.Python
code that could explain this, so I don't think so.

> I could turn my static lib into a dll but I'd rather not. I could
> also move the offending code into the extension but again I'd rather
> not.
> I'm on windows XP, using boost build v2 with the latest CVS version of
> RC_1_34_0. My compiler is the latest patched version of VC++ express.

If you're using BBv2 it should be easy for you to produce a reduced
test case (e.g. 2 source files, one for your extension and one for the
static library) that reproduces the issue... oh, whoops, I see it there
at the bottom!  Thanks.  Unfortunately I can't imagine what would
cause this problem.

> Also I'd like to say thanks for a great library,

You're welcome.

Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list