Boost C++ Libraries: Ticket #6124: Problem with copy_file in 1.47 https://svn.boost.org/trac10/ticket/6124 <p> Hi, I'm having a strange behaviour with copy_file in boost 1.47. </p> <p> I've got a file with a piece of code like this: </p> <pre class="wiki">string filename, old_filename; ... copy_file(old_filename, filename); </pre><p> It compiles, but it doesn't link. The linker says that copy_file doesn't exists: </p> <pre class="wiki">/usr/local/include/boost/filesystem/v3/operations.hpp:303: undefined reference to `boost::filesystem3::detail::copy_file(boost::filesystem3::path const&amp;, boost::filesystem3::path const&amp;, boost::filesystem3::copy_option, boost::system::error_code*)' </pre><p> I'm using other functions from the filesystem library, and if I don't include the "-lboost_filesystem" flag I got other errors, so the library is correctly found. </p> <p> The boost library is not pre-compiled -- I built it by myself, but I didn't specified any particular flag to the b2. </p> <p> Thanks -- dodomorandi </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6124 Trac 1.4.3 morandidodo@… Thu, 17 Nov 2011 08:17:05 GMT <link>https://svn.boost.org/trac10/ticket/6124#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6124#comment:1</guid> <description> <p> I found a possible cause. Take this piece of code as test: </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; using namespace boost::filesystem; int main() { copy_file("a", "b"); return 0; } </pre><p> I'm using g++ 4.5.2, and I noticed the problem occurs only when I compile the code with -std=c++0x. What I don't know is if the problem is related to the boost library or the compiler. However if I use boost 1.42 (the library provided from my Linux distribution) everything goes well. </p> <p> Any suggestion? -- dodomorandi </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 21 Nov 2011 01:07:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6124#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6124#comment:2</guid> <description> <p> I'm experiencing the same problem with g++ 4.6.1 with -std=c++0x. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 28 Nov 2011 17:34:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6124#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6124#comment:3</guid> <description> <p> Just another information, maybe it could be useful: I just installed the new Linux Mint 12. The problem is reproducible with default packages. Boost is 1.46.1, g++ 4.6.1. </p> </description> <category>Ticket</category> </item> <item> <author>morandidodo@…</author> <pubDate>Tue, 29 Nov 2011 18:35:20 GMT</pubDate> <title>status, component changed; resolution set https://svn.boost.org/trac10/ticket/6124#comment:4 https://svn.boost.org/trac10/ticket/6124#comment:4 <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>component</strong> <span class="trac-field-old">filesystem</span> → <span class="trac-field-new">Building Boost</span> </li> </ul> <p> Got the problem - finally! It's necessary to build the Boost library using the "-std=c++0x" flag, like this: ./b2 cxxflags="-std=c++0x" </p> <p> I think it's quite important to check before the compilation (using autoconf scripts, cmake scripts and so on) if the compiled libraries can be linked with the "c++0x" flag. </p> <p> However, anyone knows if there's a reason to compile the Boost without c++0x? It could be possible to compile programs using the C++03 standard? If it's completely retro-compatible maybe it could be useful to enable the c++0x flag by default, isn't it? </p> <p> -- dodomorandi </p> Ticket Beman Dawes Fri, 24 Oct 2014 16:01:18 GMT <link>https://svn.boost.org/trac10/ticket/6124#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6124#comment:5</guid> <description> <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> </description> <category>Ticket</category> </item> </channel> </rss>