[英]ERROR in compiling C++ Boost iostream library
我正在使用 boost 庫來解壓縮壓縮文件。 但是,當我使用 CMake 編譯項目時,在編譯過程中出現以下錯誤。 片段如下。
include <boost/iostreams/filtering_streambuf.hpp>
include <boost/iostreams/copy.hpp>
include <boost/iostreams/filter/gzip.hpp>
ifstream infile;
boost::iostreams::filtering_streambuf<boost::iostreams::input> inbuf;
inbuf.push(boost::iostreams::gzip_decompressor());
inbuf.push(infile);
g++ Version 4.8.5 & g++ 7.3.1 (Same error with both tries)
Using standard 17
find_package(Boost 1.67.0)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(<project-name> ${Boost_LIBRARIES})
/usr/local/include/boost/iostreams/detail/access_control.hpp: In constructor ‘boost::iostreams::detail::pub_<U>::pub_(V)’:
/usr/local/include/boost/iostreams/detail/access_control.hpp:43:42: error: class ‘boost::iostreams::detail::pub_<U>’ does not have any field named ‘v’
template<typename V> pub_(V v) : U(v) { }
/usr/local/include/boost/iostreams/detail/access_control.hpp:43:49: error: expected ‘{’ at end of input
template<typename V> pub_(V v) : U(v) { }
嘗試使用這個:
#define _TURN_OFF_PLATFORM_STRING
這可能是由於與其他包含的庫中定義的某些宏發生沖突。
如果這不適用於最新的 g++ 版本 (9.2.0),您可以嘗試切換到 Boost 1.72.0。 重新檢查您的編譯器標志,如果問題仍然存在,請使用足夠的代碼進行注釋以重現您的錯誤。
問題已解決。 需要注意的是,指令 #define _TURN_OFF_PLATFORM_STRING 需要添加到 .h/.cpp 文件的最頂部(第一行),其中正在導入正在討論的庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.