Subject: [Boost-bugs] [Boost C++ Libraries] #7678: multiple definitions of bool boost::polygon::belongs(...) by multiple #include
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-10 12:28:48
#7678: multiple definitions of bool boost::polygon::belongs(...) by multiple
#include
-------------------------------------------+--------------------------------
Reporter: Manfred <kuhnkies@â¦> | Owner: ljsimons
Type: Bugs | Status: new
Milestone: To Be Determined | Component: polygon
Version: Boost 1.52.0 | Severity: Problem
Keywords: polygon, voronoi |
-------------------------------------------+--------------------------------
Hello,
my notice:
I encountered a linker problem within the voronoi code of library
boost::polygon when using MSVS 2008. There (and I guess on many other
compilers) will be multiple definitions of function
bool boost::polygon::belongs(...)
as soon as there is direct or transitive
#include <boost/polygon/voronoi_geometry_type.hpp>
in more than one compile unit (.cpp file). This linker problem will not
occur if only one .cpp file #includes this file (see single tutorial file
libs/polygon/example/voronoi_visualizer.cpp and e.g. split this file into
class related .h/.cpp files).
my explanation:
Seemingly compiling each compile unit like foo.cpp, bar.cpp, etc. produces
a definition of
bool boost::polygon::belongs(...)
into its individual .obj-file, namely foo.obj, bar.obj, etc.. Later the
linker can not resolve which of the multiple definitions of "belongs", the
one in foo.obj or the one in bar.obj, to take when binding the executable.
my suggestion:
I could fix that problem in my local boost code by making "belongs" an
inline function.
{{{
file : boost/polygon/voronoi_geometry_type.hpp
line 36 : bool belongs( // taken from svn-trunk
altered : inline bool belongs( // my local modification
}}}
Inlining won't create any definition of "belongs" in .obj file(s) at all,
hence no multiple definitions. There may be other, better solutions that I
don't know of, of course.
Best
Manfred
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7678> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:11 UTC