Boost link error – undefined reference to boost filesystem detail copy_file( )

I had some difficulty today getting my code to link to boost::filesystem::copy_file() (linking to boost version 1.53.0, gcc v4.7.2), I suffered from link errors like this:

undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::copy_option, boost::system::error_code*)’

From reading this post, it seemed that my problem may have stemmed from my use of c++0x.


None of the suggested solutions in this thread worked for me & I double checked that had built boost with -std=c++0x.


In the end after looking through the code in filesystem/operations.hpp the only thing that fixed my linking problem was to #define BOOST_NO_CXX11_SCOPED_ENUMS before including , like this:


This may well not be the best/proper way to fix the problem but it was the only thing that worked for me..


Other relevant links that I found are here, here and here.

4 replies
  1. Robert Nitsch
    Robert Nitsch says:

    Hi Kevin,

    what information is missing from my page on that matter? If there is something I have missed, I would like to improve it.

    But it seems that I describe the same fix, except that I use a deprecated Macro (but it should still be working in Boost 1.53 and – just in case – I have added a note about that).

    Best regards,

    • Kevin Godden
      Kevin Godden says:

      Hi Robert,

      First of all I must thank you for your post on this issue, problem like this can be very hard to solve and I would be lost if guys such as yourself didn’t post your solutions! I did try #defining BOOST_NO_SCOPED_ENUMS as in you example but for some reason it didn’t seem to fix the build error for me. If I get a chance I will double-check this later again today in case I missed something!

      Best Regards,


  2. PherricOxide
    PherricOxide says:

    Thanks! I was having the exact same problem, even building Boost from source with C++11 support didn’t help. Including that enum seemed to fix my problems though.

  3. Seth
    Seth says:

    After looking through several support tickets on the boost bugtracker, all for this issue, this was the only solution I could find. This is a lot better than re-compiling boost myself, thanks.

Comments are closed.