【发布时间】:2011-08-22 22:20:05
【问题描述】:
我正在尝试从 boost 文档中编译这段代码: (http://www.boost.org/doc/libs/1_46_1/libs/iostreams/doc/tutorial/filter_usage.html)
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/filtering_stream.hpp>
namespace io = boost::iostreams;
int main()
{
io::filtering_ostream out;
out.push(compressor());
out.push(base64_encoder());
out.push(file_sink("my_file.txt"));
// write to out using std::ostream interface
}
但它拒绝编译,我得到以下错误:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../teste -I/usr/include/qt4 /QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I../teste -I. -o main.o ../teste/main.cpp
../teste/main.cpp:在函数'int main()'中:
../teste/main.cpp:9:25: 错误:“压缩器”未在此范围内声明
../teste/main.cpp:10:29: 错误:'base64_encoder' 未在此范围内声明
../teste/main.cpp:11:37: 错误:'file_sink' 未在此范围内声明
我知道我可能在做一些愚蠢的事情,但我就是看不到什么......
编辑:
顺便说一句,我已正确安装了所有 boost 库和 -dev 文件。我正在使用 QT-Creator,所以我的 .pro 文件如下所示:
SOURCES += \
main.cpp
LIBS += \
-lboost_filesystem \
-lboost_iostreams
【问题讨论】:
标签: c++ linux boost linker qt-creator