Я не могу создать простой проект, используя boost сопрограмму на машинах, использующих gcc 4.4.7 (centos6.4, redhat 6.0, 6.1 и т. Д.). Тот же проект прекрасно работает на машинах под управлением gcc 4.8.3 (fedora 19, centos 7.0).
Так как Boost 1.55 история версий перечисляет gcc 4.4.7 как протестированный компилятор, что я делаю не так?
Простой тестовый файл состоит из следующего файла main.cpp:
#include <iostream>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/coroutine/coroutine.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
using namespace std;
typedef boost::coroutines::coroutine<int()> routine_t;
// The implementation routine of the coroutine.
void xrange_impl(routine_t::caller_type& yield, int limit)
{
for(int i = 0; i < limit; i++)
{
yield(i); // return results back to the caller
}
}
int main()
{
routine_t foo(boost::bind(xrange_impl, _1, 10000));
return 0;
};
Ошибки компиляции, которые я получаю:
Building CXX object corotest/CMakeFiles/corotest.dir/src/main.cpp.o
In file included from /users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:29,
from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp: In instantiation of ‘boost::detail::is_function_chooser<false>::result_<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:60: instantiated from ‘boost::detail::is_function_impl<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:102: instantiated from ‘boost::is_function<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:354: instantiated from ‘const bool boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480: instantiated from ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59: instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:52: error: forming pointer to reference type ‘boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&’
In file included from /users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:29,
from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp: In instantiation of ‘boost::is_function<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:354: instantiated from ‘const bool boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480: instantiated from ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59: instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:102: error: ‘value’ is not a member of ‘boost::detail::is_function_impl<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
In file included from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp: In instantiation of ‘const bool boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480: instantiated from ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59: instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:354: error: ‘value’ is not a member of ‘boost::is_function<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
In file included from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp: In instantiation of ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59: instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480: error: ‘boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’ is not a valid template argument for type ‘bool’ because it is a non-constant expression
In file included from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:2:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp: In instantiation of ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’:
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59: error: ‘value’ is not a member of ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp: In function ‘int main()’:
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: error: no matching function for call to ‘boost::coroutines::coroutine<int(), 0>::coroutine(boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >)’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/coroutine/v1/coroutine.hpp:600: note: candidates are: boost::coroutines::coroutine<Signature, 0>::coroutine(boost::rv<boost::coroutines::coroutine<Signature, 0> >&) [with Signature = int()]
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/coroutine/v1/coroutine.hpp:155: note: boost::coroutines::coroutine<Signature, 0>::coroutine() [with Signature = int()]
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/coroutine/v1/coroutine.hpp:119: note: boost::coroutines::coroutine<Signature, 0>::coroutine(boost::coroutines::coroutine<Signature, 0>&) [with Signature = int()]
make[2]: *** [corotest/CMakeFiles/corotest.dir/src/main.cpp.o] Error 1
make[1]: *** [corotest/CMakeFiles/corotest.dir/all] Error 2
make: *** [all] Error 2
Вывод из «gcc —version» на машине, где он НЕ будет собран:
$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Вывод из «gcc —version» на машине, где он будет построен:
$ gcc --version
gcc (GCC) 4.8.3 20140624 (Red Hat 4.8.3-1)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Скомпилируйте ваш код с -std=c++0x
,
Это сработало для меня в аналогичном случае, когда boost::bind()
не был решен правильно.