我试图将Visual C ++ 2017中开发的C ++项目移植到redhat linux gcc 8.2。我在使用make命令时遇到了一些奇怪的错误
Scanning dependencies of target XXX
[ 7%] Building CXX object CMakeFiles/XXX.dir/cashflowengine.cpp.o
In file included from /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++allocator.h:33:0,
from /usr/include/c++/4.8.2/bits/allocator.h:46,
from /usr/include/c++/4.8.2/string:41,
from /home/research/boost_library/boost_1_68_0/boost/program_options/errors.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:12,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::basic_istringstream<char>; _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}; _Tp = std::basic_istringstream<char>]’:
/usr/include/c++/4.8.2/bits/alloc_traits.h:254:4: required from ‘static typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::basic_istringstream<char>; _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}; _Alloc = std::allocator<std::basic_istringstream<char> >; typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type = void]’
/usr/include/c++/4.8.2/bits/alloc_traits.h:393:57: required from ‘static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::basic_istringstream<char>; _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}; _Alloc = std::allocator<std::basic_istringstream<char> >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]’
/usr/include/c++/4.8.2/bits/vector.tcc:97:40: required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}; _Tp = std::basic_istringstream<char>; _Alloc = std::allocator<std::basic_istringstream<char> >]’
/usr/include/c++/4.8.2/bits/stl_vector.h:920:36: required from ‘void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::basic_istringstream<char>; _Alloc = std::allocator<std::basic_istringstream<char> >; std::vector<_Tp, _Alloc>::value_type = std::basic_istringstream<char>]’
/home/research/QZ/files/XXX/utility.h:2413:37: required from here
/usr/include/c++/4.8.2/ext/new_allocator.h:120:4: error: use of deleted function ‘std::basic_istringstream<char>::basic_istringstream(const std::basic_istringstream<char>&)’
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
In file included from /usr/include/c++/4.8.2/complex:45:0,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/sstream:272:11: note: ‘std::basic_istringstream<char>::basic_istringstream(const std::basic_istringstream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
class basic_istringstream : public basic_istream<_CharT, _Traits>
^
/usr/include/c++/4.8.2/sstream:272:11: error: use of deleted function ‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’
In file included from /usr/include/c++/4.8.2/sstream:38:0,
from /usr/include/c++/4.8.2/complex:45,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/istream:58:11: note: ‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
class basic_istream : virtual public basic_ios<_CharT, _Traits>
^
/usr/include/c++/4.8.2/istream:58:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
In file included from /usr/include/c++/4.8.2/ios:44:0,
from /usr/include/c++/4.8.2/istream:38,
from /usr/include/c++/4.8.2/sstream:38,
from /usr/include/c++/4.8.2/complex:45,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/bits/basic_ios.h:66:11: note: ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’ is implicitly deleted because the default definition would be ill-formed:
class basic_ios : public ios_base
^
In file included from /usr/include/c++/4.8.2/ios:42:0,
from /usr/include/c++/4.8.2/istream:38,
from /usr/include/c++/4.8.2/sstream:38,
from /usr/include/c++/4.8.2/complex:45,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/bits/ios_base.h:786:5: error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private
ios_base(const ios_base&);
^
In file included from /usr/include/c++/4.8.2/ios:44:0,
from /usr/include/c++/4.8.2/istream:38,
from /usr/include/c++/4.8.2/sstream:38,
from /usr/include/c++/4.8.2/complex:45,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/bits/basic_ios.h:66:11: error: within this context
class basic_ios : public ios_base
^
In file included from /usr/include/c++/4.8.2/complex:45:0,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/sstream:272:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
class basic_istringstream : public basic_istream<_CharT, _Traits>
^
/usr/include/c++/4.8.2/sstream:272:11: error: use of deleted function ‘std::basic_stringbuf<char>::basic_stringbuf(const std::basic_stringbuf<char>&)’
/usr/include/c++/4.8.2/sstream:64:11: note: ‘std::basic_stringbuf<char>::basic_stringbuf(const std::basic_stringbuf<char>&)’ is implicitly deleted because the default definition would be ill-formed:
class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
^
In file included from /usr/include/c++/4.8.2/ios:43:0,
from /usr/include/c++/4.8.2/istream:38,
from /usr/include/c++/4.8.2/sstream:38,
from /usr/include/c++/4.8.2/complex:45,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/streambuf:802:7: error: ‘std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]’ is private
basic_streambuf(const basic_streambuf& __sb)
^
In file included from /usr/include/c++/4.8.2/complex:45:0,
from /home/research/boost_library/boost_1_68_0/boost/detail/container_fwd.hpp:98,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/extensions.hpp:22,
from /home/research/boost_library/boost_1_68_0/boost/container_hash/hash.hpp:760,
from /home/research/boost_library/boost_1_68_0/boost/type_index/stl_type_index.hpp:42,
from /home/research/boost_library/boost_1_68_0/boost/type_index.hpp:29,
from /home/research/boost_library/boost_1_68_0/boost/any.hpp:20,
from /home/research/boost_library/boost_1_68_0/boost/program_options/value_semantic.hpp:12,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:13,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/sstream:64:11: error: within this context
class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
^
In file included from /usr/include/c++/4.8.2/vector:62:0,
from /home/research/boost_library/boost_1_68_0/boost/program_options/errors.hpp:14,
from /home/research/boost_library/boost_1_68_0/boost/program_options/options_description.hpp:12,
from /home/research/QZ/files/XXX/FileSettings.h:4,
from /home/research/QZ/files/XXX/Assumption.h:6,
from /home/research/QZ/files/XXX/DynamicTables.h:4,
from /home/research/QZ/files/XXX/stdafx.h:3,
from /home/research/QZ/files/XXX/cashflowengine.cpp:1:
/usr/include/c++/4.8.2/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::basic_istringstream<char>; _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}]’:
/usr/include/c++/4.8.2/bits/stl_uninitialized.h:75:53: required from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<std::basic_istringstream<char>*>; _ForwardIterator = std::basic_istringstream<char>*; bool _TrivialValueTypes = false]’
/usr/include/c++/4.8.2/bits/stl_uninitialized.h:117:41: required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<std::basic_istringstream<char>*>; _ForwardIterator = std::basic_istringstream<char>*]’
/usr/include/c++/4.8.2/bits/stl_uninitialized.h:258:63: required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::move_iterator<std::basic_istringstream<char>*>; _ForwardIterator = std::basic_istringstream<char>*; _Tp = std::basic_istringstream<char>]’
/usr/include/c++/4.8.2/bits/stl_uninitialized.h:281:69: required from ‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = std::basic_istringstream<char>*; _ForwardIterator = std::basic_istringstream<char>*; _Allocator = std::allocator<std::basic_istringstream<char> >]’
/usr/include/c++/4.8.2/bits/vector.tcc:415:43: required from ‘void std::vector<_Tp, _Alloc>::_M_emplace_back_aux(_Args&& ...) [with _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}; _Tp = std::basic_istringstream<char>; _Alloc = std::allocator<std::basic_istringstream<char> >]’
/usr/include/c++/4.8.2/bits/vector.tcc:101:54: required from ‘void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >}; _Tp = std::basic_istringstream<char>; _Alloc = std::allocator<std::basic_istringstream<char> >]’
/usr/include/c++/4.8.2/bits/stl_vector.h:920:36: required from ‘void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::basic_istringstream<char>; _Alloc = std::allocator<std::basic_istringstream<char> >; std::vector<_Tp, _Alloc>::value_type = std::basic_istringstream<char>]’
/home/research/QZ/files/XXX/utility.h:2413:37: required from here
/usr/include/c++/4.8.2/bits/stl_construct.h:75:7: error: use of deleted function ‘std::basic_istringstream<char>::basic_istringstream(const std::basic_istringstream<char>&)’
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
^
make[2]: *** [CMakeFiles/XXX.dir/cashflowengine.cpp.o] Error 1
make[1]: *** [CMakeFiles/XXX.dir/all] Error 2
make: *** [all] Error 2
指出的大多数错误都在C ++包含文件或boost库中。对于项目文件,它们指向包含iostream或sstream的行。
我对gcc不太熟悉,这可能是一个愚蠢的问题。我注意到包含文件在/usr/include/4.8.2中。我正在使用gcc 8.2。这是正确的文件夹还是我的包含文件版本已过时。如果是这样,我该如何更新包含库?
如果包含文件版本有问题,该如何调试?谢谢
跟进:
结果在代码(utility.h)中我有类似的东西
vector<istringstream> sstr;
TrimString(str1);
TrimString(str2);
sstr.push_back(istringstream(str1));
sstr.push_back(istringstream(str2));
注释掉此部分可解决问题。非常感谢您的帮助。
答案 0 :(得分:0)
/usr/include/c++/4.8.2/ext/new_allocator.h:120:4: error: use of deleted function ‘std::basic_istringstream<char>::basic_istringstream(const std::basic_istringstream<char>&)’
这表明您正在尝试复制std :: basic_istream。
std :: basic_istream具有明确删除的副本构造函数