Boost C++ Libraries: Ticket #995: 'multiply defined symbols' when including <boost/filesystem.hpp> in different source files https://svn.boost.org/trac10/ticket/995 <p> When &lt;boost/filesystem.hpp&gt; is included in different source files, the linker complains about 'multiply defined symbols' </p> <p> Attached: two source files that reproduce the error when compiled and linked in the same project. </p> <p> boost-1.34.0 MSVC 7.0 </p> <pre class="wiki">test2.obj : error LNK2005: "class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __cdecl boost::filesystem::extension(class boost::filesystem::basic_path&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct boost::filesystem::path_traits&gt; const &amp;)" (?extension@filesystem@boost@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem@boost@@@12@@Z) already defined in test.obj test2.obj : error LNK2005: "class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __cdecl boost::filesystem::basename(class boost::filesystem::basic_path&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct boost::filesystem::path_traits&gt; const &amp;)" (?basename@filesystem@boost@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem@boost@@@12@@Z) already defined in test.obj Release/test.exe : fatal error LNK1169: one or more multiply defined symbols found </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/995 Trac 1.4.3 anonymous Fri, 25 May 2007 08:04:31 GMT attachment set https://svn.boost.org/trac10/ticket/995 https://svn.boost.org/trac10/ticket/995 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> first file </p> Ticket anonymous Fri, 25 May 2007 08:04:49 GMT attachment set https://svn.boost.org/trac10/ticket/995 https://svn.boost.org/trac10/ticket/995 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test2.cpp</span> </li> </ul> <p> second file </p> Ticket anonymous Fri, 25 May 2007 08:38:09 GMT <link>https://svn.boost.org/trac10/ticket/995#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/995#comment:1</guid> <description> <p> Workaround (works for MSVC 7.0): </p> <p> add "/force:multiple" to advanced linker options </p> </description> <category>Ticket</category> </item> <item> <author>frederic.bron@…</author> <pubDate>Mon, 02 Jul 2007 16:57:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/995#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/995#comment:2</guid> <description> <p> There is an "inline" missing in filesystem/convenience.hpp </p> <p> # define BOOST_FS_FUNC_STRING std::string </p> <p> should be </p> <p> # define BOOST_FS_FUNC_STRING inline std::string </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Wed, 11 Jul 2007 02:08:09 GMT</pubDate> <title>owner set https://svn.boost.org/trac10/ticket/995#comment:3 https://svn.boost.org/trac10/ticket/995#comment:3 <ul> <li><strong>owner</strong> set to <span class="trac-author">Beman Dawes</span> </li> </ul> Ticket mkl Thu, 26 Jul 2007 07:33:37 GMT <link>https://svn.boost.org/trac10/ticket/995#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/995#comment:4</guid> <description> <p> Oh, the fix didn't make it into 1_34_1 :( </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Benjamin Eikel</dc:creator> <pubDate>Fri, 10 Aug 2007 10:32:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/995#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/995#comment:5</guid> <description> <p> This problem exists with mingw/gcc too. But the suggested workaround works. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Benjamin Eikel</dc:creator> <pubDate>Fri, 10 Aug 2007 10:33:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/995#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/995#comment:5</guid> <description> <p> This problem exists with mingw/gcc too. But the suggestes workaround works. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Fri, 10 Aug 2007 12:53:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/995#comment:7 https://svn.boost.org/trac10/ticket/995#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/38567" title="Fix #995 by adding inline">[38567]</a>) Fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/995" title="#995: Bugs: 'multiply defined symbols' when including &lt;boost/filesystem.hpp&gt; in ... (closed: fixed)">#995</a> by adding inline </p> Ticket