Boost C++ Libraries: Ticket #10038: filesystem library with -std=c++11 causes undefined reference to copy_file https://svn.boost.org/trac10/ticket/10038 <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; int main(void) { boost::filesystem::copy_file("a", "b"); return 0; } </pre><p> Using either g++ 4.8.1 or clang++ 3.5 when I enable the compiler option -std=c++11, the boost::filesystem::detail::copy_file cannot be found in the library: </p> <pre class="wiki">root@dvm-3:/tmp# g++ --version g++ (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1 # g++ -g -I/usr/include/boost-1_56 fscopy.cpp -o fscopy -lboost_filesystem-clang35-mt-d-1_56 -lboost_system-clang35-mt-d-1_56 # g++ -std=c++11 -g -I/usr/include/boost-1_56 fscopy.cpp -o fscopy -lboost_filesystem-clang35-mt-d-1_56 -lboost_system-clang35-mt-d-1_56 /usr/include/boost-1_56/boost/filesystem/operations.hpp:385: error: undefined reference to 'boost::filesystem::detail::copy_file(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;, boost::filesystem::copy_option, boost::system::error_code*)' collect2: error: ld returned 1 exit status # /usr/bin/clang++ -g -I/usr/include/boost-1_56 fscopy.cpp -o fscopy -lboost_filesystem-clang35-mt-d-1_56 -lboost_system-clang35-mt-d-1_56 # /usr/bin/clang++ -std=c++11 -g -I/usr/include/boost-1_56 fscopy.cpp -o fscopy -lboost_filesystem-clang35-mt-d-1_56 -lboost_system-clang35-mt-d-1_56 /usr/include/boost-1_56/boost/filesystem/operations.hpp:385: error: undefined reference to 'boost::filesystem::detail::copy_file(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;, boost::filesystem::copy_option, boost::system::error_code*)' clang: error: linker command failed with exit code 1 (use -v to see invocation) </pre><p> The boost 1.56 libraries were built with clang-3.5 on Ubuntu 12.04.2 LTS with libstdc++ from g++-4.8.1 installed. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10038 Trac 1.4.3 jim.king@… Sun, 11 May 2014 11:15:00 GMT <link>https://svn.boost.org/trac10/ticket/10038#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:1</guid> <description> <p> Using "strings" I extracted the mangled name from the library: </p> <pre class="wiki"># strings /usr/lib/libboost_filesystem-clang35-mt-d-1_56.so | grep copy_file _ZN5boost10filesystem6detail9copy_fileERKNS0_4pathES4_NS0_11copy_option9enum_typeEPNS_6system10error_codeE ... </pre><p> This demangles to: </p> <pre class="wiki">boost::filesystem::detail::copy_file(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;, boost::filesystem::copy_option::enum_type, boost::system::error_code*) </pre><p> The ::enum_type is a different signature. </p> <p> I built boost 1.56 with: </p> <pre class="wiki">./b2 toolset=clang --prefix=/usr --build-type=complete --build-dir=... --layout=versioned install </pre><p> (where ... was a directory outside the source directory) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 07 Jul 2014 21:28:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:2</guid> <description> <p> I have exactly the same issue with Boost 1.55 (using Clang 3.5 under Ubuntu 14.04). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 09 Jul 2014 15:39:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:3</guid> <description> <p> The problem is still there in Boost 1.56 RC1 released yesterday (using Clang 3.5). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 24 Oct 2014 09:02:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:4</guid> <description> <p> I think is a duplicate of ticked <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6124" title="#6124: Bugs: Problem with copy_file in 1.47 (closed: fixed)">#6124</a> </p> </description> <category>Ticket</category> </item> <item> <author>jim.king@…</author> <pubDate>Fri, 24 Oct 2014 11:34:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:5</guid> <description> <p> It looks like that other ticket was marked resolved because someone found a workaround, not because the root cause was addressed. That said, the workaround might be helpful. Thanks for connecting the dots... so the question remains, can one use a single c++0x build to satisfy c++0x and non-c++0x, or do we need to add yet another variant to the build cycle and another library name variant to the output library file names? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Fri, 24 Oct 2014 16:03:19 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/10038#comment:6 https://svn.boost.org/trac10/ticket/10038#comment:6 <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> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6124" title="#6124: Bugs: Problem with copy_file in 1.47 (closed: fixed)">#6124</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6779" title="#6779: Bugs: Scoped enums break linking compatibility between C++98 and C++11 (closed: fixed)">#6779</a>, and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10038" title="#10038: Bugs: filesystem library with -std=c++11 causes undefined reference to copy_file (closed: fixed)">#10038</a> are all the same problem. The private library interface has been changed to use a plain-old C++03 enum. This is the fix suggested by Andy in 6779. </p> <p> The fix was too late for 1.57 beta 1, but should be in the final 1.57 release. </p> <p> Thanks for your patience, </p> <p> --Beman </p> Ticket bruno@… Thu, 19 Mar 2015 17:11:04 GMT <link>https://svn.boost.org/trac10/ticket/10038#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:7</guid> <description> <p> I guess a backport to 1.56 would save some pain to lot of people </p> </description> <category>Ticket</category> </item> <item> <author>mancha <mancha1@…></author> <pubDate>Mon, 11 May 2015 15:25:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10038#comment:7" title="Comment 7">bruno@…</a>: </p> <blockquote class="citation"> <p> I guess a backport to 1.56 would save some pain to lot of people </p> </blockquote> <p> <br />I've prepared a backport to 1.56: </p> <p> <a class="ext-link" href="http://sf.net/projects/mancha/files/misc/boost-1.56.0_copy_file.diff"><span class="icon">​</span>http://sf.net/projects/mancha/files/misc/boost-1.56.0_copy_file.diff</a> </p> <p> --mancha </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 11 Dec 2015 23:38:49 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/10038 https://svn.boost.org/trac10/ticket/10038 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bytecoind.bash-completion</span> </li> </ul> Ticket anonymous Sun, 31 Jan 2016 14:52:21 GMT <link>https://svn.boost.org/trac10/ticket/10038#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:9</guid> <description> <p> I have exactly the same issue with latest Boost 1.60 (using Clang 3.7 with c++11 under Gentoo). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 26 Oct 2016 03:24:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:10</guid> <description> <p> How to deal with this problem? </p> <p> I have exactly the same issue with Boost 1.54.0(using arm-gcc 4.8.3 under Android) </p> <p> How to write the Makefile via Android.mk? </p> <p> libboost_system, libboost_thread, libboost_filesystem and libboost_log are used. </p> <p> When I build the libboost_log, the issue occurs. </p> <p> The cxx_flags of filesystem is: </p> <p> -std=c++0x -Wextra -pedantic -Wno-long-long -ansi -fpermissive -fexceptions -Wno-variadic-macros -Wunused-function -DBOOST_SYSTEM_NO_DEPRECATED </p> <p> It successed </p> <p> and the boost_log is: </p> <p> -std=c++0x -fexceptions -fpermissive -Wmissing-field-initializers -ftemplate-depth-1024 -fno-strict-aliasing -DBOOST_LOG_WITHOUT_EVENT_LOG -DBOOST_LOG_USE_NATIVE_SYSLOG -DBOOST_SPIRIT_USE_PHOENIX_V3 </p> <p> boost/filesystem/operations.hpp:384: undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&amp;, boost::filesystem::path const&amp;, boost::filesystem::copy_option, boost::system::error_code*)' </p> </description> <category>Ticket</category> </item> <item> <author>James E. King, III <jking@…></author> <pubDate>Wed, 26 Oct 2016 12:33:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:11</guid> <description> <p> There is a report that this was seen in boost-1.60. Shouldn't it be rejected/reopened until that is proven incorrect? </p> </description> <category>Ticket</category> </item> <item> <author>shanakard@…</author> <pubDate>Thu, 07 Jun 2018 10:51:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10038#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10038#comment:12</guid> <description> <p> I get the same error with boost 1.67 on RHEL 7.5 </p> </description> <category>Ticket</category> </item> </channel> </rss>