Modify

Ticket #7678 (closed Bugs: fixed)

Opened 18 months ago

Last modified 14 months ago

multiple definitions of bool boost::polygon::belongs(...) by multiple #include

Reported by: Manfred <kuhnkies@…> Owned by: asydorchuk
Milestone: Boost 1.53.0 Component: polygon
Version: Boost 1.52.0 Severity: Problem
Keywords: polygon, voronoi Cc:

Description

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

Attachments

Change History

comment:1 Changed 18 months ago by asydorchuk

  • Owner changed from ljsimons to asydorchuk
  • Status changed from new to assigned

comment:2 Changed 17 months ago by asydorchuk

  • Milestone changed from To Be Determined to Boost 1.53.0

comment:3 Changed 17 months ago by asydorchuk

Hi Manfred,

Thank you for the report and suggested fix. The change was pushed to trunk today and will become public in Boost 1.53.

Regards, Andrii

comment:4 Changed 14 months ago by asydorchuk

  • Status changed from assigned to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.