boost :: filesystem :: copy_file()在c ++ 11中缺少符号 [英] boost::filesystem::copy_file() missing symbol in c++11
问题描述
如果Boost编译时没有 C ++ 11支持,则boost::filesystem
使用模拟范围的枚举器.如果您随后使用此内置Boost并在具有C ++ 11支持的项目中使用它,则由于boost::filesystem::copy_file()
的声明已更改,您最终会丢失符号.
If Boost is compiled without C++11 support the boost::filesystem
uses emulated scoped enumerators. If you then take this built Boost and use it in a project with C++11 support you end up with a missing symbol because the declaration of boost::filesystem::copy_file()
has changed.
有一个简单的解决方法:
There is an easy fix for this:
# if __cplusplus >= 201103L
# define NO_SCOPED_ENUMS
# endif
# ifdef NO_SCOPED_ENUMS
# if BOOST_VERSION < 105000
# ifndef BOOST_NO_SCOPED_ENUMS
# define BOOST_NO_SCOPED_ENUMS
# define REMOVE
# endif
# else
# ifndef BOOST_NO_CXX11_SCOPED_ENUMS
# define BOOST_NO_CXX11_SCOPED_ENUMS
# define REMOVE
# endif
# endif
# endif
# include "boost/filesystem.hpp"
# if defined(NO_SCOPED_ENUMS) && defined(REMOVE)
# undef REMOVE
# if BOOST_VERSION < 105000
# undef BOOST_NO_SCOPED_ENUMS
# else
# undef BOOST_NO_CXX11_SCOPED_ENUMS
# endif
# endif
此预处理位根据Boost版本定义BOOST_NO_SCOPED_ENUMS
或BOOST_NO_CXX11_SCOPED_ENUMS
,包括boost/filesystem
,如果以前没有定义,则将其再次删除(为安全起见)
This preprocess bit defines either the BOOST_NO_SCOPED_ENUMS
or BOOST_NO_CXX11_SCOPED_ENUMS
depending on the Boost version, includes boost/filesystem
and then removes it again if it wasn't defined before (to be safe)
现在,这里的问题是,当我们为C ++ 11编译时,作用域枚举器已关闭:
Now the issue here is that the scoped enumerators are turned off when we are compiling for C++11:
# if __cplusplus >= 201103L
# define NO_SCOPED_ENUMS
# endif
但是,如果Boost实际上是使用C ++ 11支持的编译的,则它将再次中断,因为声明将被更改.它必须是这样的:
However, if Boost has actually been compiled with C++11 support this will break again because the declaration will be changed. It needs to be something like:
// BOOST_COMPILED_WITH_CXX11 doesn't exist
# if (__cplusplus >= 201103L) && !defined(BOOST_COMPILED_WITH_CXX11)
# define NO_SCOPED_ENUMS
# endif
这是我的问题所在:
tl; dr-我可以确定Boost是否在C ++ 11支持下编译吗?