C ++ BOOST对`boost :: filesystem :: detail :: copy_file的未定义引用 [英] C++ BOOST undefined reference to `boost::filesystem::detail::copy_file

查看:902
本文介绍了C ++ BOOST对`boost :: filesystem :: detail :: copy_file的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么boost::filesystem::copy_file给我带来麻烦.

I have no clue why boost::filesystem::copy_file is making trouble for me.

对`boost :: filesystem :: detail :: copy_file

undefined reference to `boost::filesystem::detail::copy_file

// g++ -std=c++11 test.cpp -lboost_filesystem -lboost_system -lrt -lboost_wave

#include <boost/filesystem.hpp>

int main()
{

    boost::filesystem::create_directory("aaa");
    // ok


    boost::filesystem::copy_file("f1","f2");
    // /tmp/ccNWZltB.o: In function `boost::filesystem::copy_file(boost::filesystem::path const&, boost::filesystem::path const&)':
    // test.cpp:(.text._ZN5boost10filesystem9copy_fileERKNS0_4pathES3_[_ZN5boost10filesystem9copy_fileERKNS0_4pathES3_]+0x26): undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::copy_option, boost::system::error_code*)'
    // collect2: error: ld returned 1 exit status


    return 0;
}

boost的源代码或其帮助没有任何启发. :

I got no inspiration from the source code of boost or its help:

  inline
  void copy_file(const path& from, const path& to,   // See ticket #2925
                 BOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec)
                                       {detail::copy_file(from, to, option, &ec);}

即使这样的简单的示例也不适合我.

Even such a simple example does not work for me.

平台:Linux Ubuntu 64

推荐答案

此问题有解决方法,请替换

There is a workaround for this problem, replace

#include <boost/filesystem.hpp>

使用

#define BOOST_NO_CXX11_SCOPED_ENUMS
#include <boost/filesystem.hpp>
#undef BOOST_NO_CXX11_SCOPED_ENUMS

或者最好将-DBOOST_NO_CXX11_SCOPED_ENUMS添加到您的编译器标志中

Or, preferably, add -DBOOST_NO_CXX11_SCOPED_ENUMS to your compiler flags

这篇关于C ++ BOOST对`boost :: filesystem :: detail :: copy_file的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆