Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ G++;构建示例Boost代码_C++_Boost_G++ - Fatal编程技术网

C++ G++;构建示例Boost代码

C++ G++;构建示例Boost代码,c++,boost,g++,C++,Boost,G++,我正试图从他们的网站上构建一个boost示例代码 在Ubuntu 14.04和G++4.8上 代码如下: #include <boost/mpl/vector.hpp> #include <boost/gil/extension/dynamic_image/any_image.hpp> #include <boost/gil/extension/io/jpeg_dynamic_io.hpp> int main() { using namespace

我正试图从他们的网站上构建一个boost示例代码

在Ubuntu 14.04和G++4.8上

代码如下:

#include <boost/mpl/vector.hpp>
#include <boost/gil/extension/dynamic_image/any_image.hpp>
#include <boost/gil/extension/io/jpeg_dynamic_io.hpp>

int main() {
    using namespace boost::gil;

    typedef boost::mpl::vector<gray8_image_t, rgb8_image_t, gray16_image_t, rgb16_image_t> my_images_t;

    any_image<my_images_t> dynamic_img;
    jpeg_read_image("test.jpg",dynamic_img);

    // Save the image upside down, preserving its native color space and channel depth
    jpeg_write_view("out-dynamic_image.jpg",flipped_up_down_view(const_view(dynamic_img)));

    return 0;
}
产生错误:

In file included from /usr/include/c++/4.8/vector:64:0,
                 from kboost/boost/gil/extension/io/jpeg_io_private.hpp:24,
                 from kboost/boost/gil/extension/io/jpeg_io.hpp:32,
                 from kboost/boost/gil/extension/io/jpeg_dynamic_io.hpp:31,
                 from dynamic_image.cpp:20:
/usr/include/c++/4.8/bits/stl_vector.h:117:7: error: ‘std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type& std::_Vector_base<_Tp, _Alloc>::_M_get_Tp_allocator()’ cannot be overloaded
       _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:113:7: error: with ‘std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type& std::_Vector_base<_Tp, _Alloc>::_M_get_Tp_allocator()’
       _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:547:7: error: ‘std::vector<_Tp, _Alloc>::const_iterator std::vector<_Tp, _Alloc>::begin()’ cannot be overloaded
       begin() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:538:7: error: with ‘std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::begin()’
       begin() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:565:7: error: ‘std::vector<_Tp, _Alloc>::const_iterator std::vector<_Tp, _Alloc>::end()’ cannot be overloaded
       end() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:556:7: error: with ‘std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::end()’
       end() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:583:7: error: ‘std::vector<_Tp, _Alloc>::const_reverse_iterator std::vector<_Tp, _Alloc>::rbegin()’ cannot be overloaded
       rbegin() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:574:7: error: with ‘std::vector<_Tp, _Alloc>::reverse_iterator std::vector<_Tp, _Alloc>::rbegin()’
       rbegin() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:601:7: error: ‘std::vector<_Tp, _Alloc>::const_reverse_iterator std::vector<_Tp, _Alloc>::rend()’ cannot be overloaded
       rend() const _GLIBCXX_NOEXCEPT

尝试使用
-std=c++11
-std=c++0x
谢谢!这让我克服了第一组错误。更新的问题有更多错误:(这很奇怪。在包含BOOST头之前,您可以尝试
#定义BOOST\u NO\u INCLASS\u MEMBER\u初始化
,但是g++4.8在类内初始化一个
静态常量bool
应该没有问题。尝试
g++--version
检查是否使用了正确的编译器?向问题添加了g++版本输出。添加
-DBOOST\u NO\u INCLASS\u MEMBER\u INITIALIZATION处理了这些错误,但仍然存在更多的错误,我认为这些错误也不应该是错误。在这里,任何-std=和任何g++都无法复制。您使用的是哪个版本的boost?
In file included from /usr/include/c++/4.8/vector:64:0,
                 from kboost/boost/gil/extension/io/jpeg_io_private.hpp:24,
                 from kboost/boost/gil/extension/io/jpeg_io.hpp:32,
                 from kboost/boost/gil/extension/io/jpeg_dynamic_io.hpp:31,
                 from dynamic_image.cpp:20:
/usr/include/c++/4.8/bits/stl_vector.h:117:7: error: ‘std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type& std::_Vector_base<_Tp, _Alloc>::_M_get_Tp_allocator()’ cannot be overloaded
       _M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:113:7: error: with ‘std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type& std::_Vector_base<_Tp, _Alloc>::_M_get_Tp_allocator()’
       _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:547:7: error: ‘std::vector<_Tp, _Alloc>::const_iterator std::vector<_Tp, _Alloc>::begin()’ cannot be overloaded
       begin() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:538:7: error: with ‘std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::begin()’
       begin() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:565:7: error: ‘std::vector<_Tp, _Alloc>::const_iterator std::vector<_Tp, _Alloc>::end()’ cannot be overloaded
       end() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:556:7: error: with ‘std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::end()’
       end() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:583:7: error: ‘std::vector<_Tp, _Alloc>::const_reverse_iterator std::vector<_Tp, _Alloc>::rbegin()’ cannot be overloaded
       rbegin() const _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:574:7: error: with ‘std::vector<_Tp, _Alloc>::reverse_iterator std::vector<_Tp, _Alloc>::rbegin()’
       rbegin() _GLIBCXX_NOEXCEPT
       ^
/usr/include/c++/4.8/bits/stl_vector.h:601:7: error: ‘std::vector<_Tp, _Alloc>::const_reverse_iterator std::vector<_Tp, _Alloc>::rend()’ cannot be overloaded
       rend() const _GLIBCXX_NOEXCEPT
In file included from kboost/boost/config.hpp:61:0,
                 from kboost/boost/mpl/aux_/config/msvc.hpp:19,
                 from kboost/boost/mpl/aux_/config/adl.hpp:17,
                 from kboost/boost/mpl/aux_/adl_barrier.hpp:17,
                 from kboost/boost/mpl/bool_fwd.hpp:17,
                 from kboost/boost/mpl/bool.hpp:17,
                 from kboost/boost/mpl/aux_/na.hpp:17,
                 from kboost/boost/mpl/vector.hpp:19,
                 from dynamic_image.cpp:18:
kboost/boost/gil/extension/io/jpeg_io_private.hpp:37:45: error: ISO C++ forbids in-class initialization of non-const static member ‘boost::gil::detail::jpeg_read_support_private<Channel, ColorSpace>::is_supported’
     BOOST_STATIC_CONSTANT(bool,is_supported=false);
                                             ^
kboost/boost/gil/extension/io/jpeg_io_private.hpp:38:52: error: ISO C++ forbids in-class initialization of non-const static member ‘boost::gil::detail::jpeg_read_support_private<Channel, ColorSpace>::color_type’
     BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=JCS_UNKNOWN);
                                                    ^
g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
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.