Boost C++ Libraries: Ticket #7678: multiple definitions of bool boost::polygon::belongs(...) by multiple #include https://svn.boost.org/trac10/ticket/7678 <p> Hello, </p> <p> my notice: </p> <p> 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 </p> <blockquote> <p> bool boost::polygon::belongs(...) </p> </blockquote> <p> as soon as there is direct or transitive </p> <blockquote> <p> #include &lt;boost/polygon/voronoi_geometry_type.hpp&gt; </p> </blockquote> <p> 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). </p> <p> my explanation: </p> <p> Seemingly compiling each compile unit like foo.cpp, bar.cpp, etc. produces a definition of </p> <blockquote> <p> bool boost::polygon::belongs(...) </p> </blockquote> <p> 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. </p> <p> my suggestion: </p> <p> I could fix that problem in my local boost code by making "belongs" an inline function. </p> <pre class="wiki"> file : boost/polygon/voronoi_geometry_type.hpp line 36 : bool belongs( // taken from svn-trunk altered : inline bool belongs( // my local modification </pre><p> 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. </p> <p> Best </p> <blockquote> <p> Manfred </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7678 Trac 1.4.3 Andrii Sydorchuk Wed, 14 Nov 2012 11:36:18 GMT owner, status changed https://svn.boost.org/trac10/ticket/7678#comment:1 https://svn.boost.org/trac10/ticket/7678#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Lucanus Simonson</span> to <span class="trac-author">Andrii Sydorchuk</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Andrii Sydorchuk Mon, 19 Nov 2012 22:57:32 GMT milestone changed https://svn.boost.org/trac10/ticket/7678#comment:2 https://svn.boost.org/trac10/ticket/7678#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.53.0</span> </li> </ul> Ticket Andrii Sydorchuk Mon, 19 Nov 2012 22:58:55 GMT <link>https://svn.boost.org/trac10/ticket/7678#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7678#comment:3</guid> <description> <p> Hi Manfred, </p> <p> Thank you for the report and suggested fix. The change was pushed to trunk today and will become public in Boost 1.53. </p> <p> Regards, Andrii </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrii Sydorchuk</dc:creator> <pubDate>Wed, 06 Mar 2013 22:55:04 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7678#comment:4 https://svn.boost.org/trac10/ticket/7678#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket