c++11 和 boost_filesystem cout 和 printf 不起作用

标签 c++ boost c++11 printf cout

我在使用 boost/filesystem.hpp 时遇到了 printf 和 cout 的问题

我使用 mingw 设置在 eclipse juno 中创建了一个 c++ 项目

objectfile.hpp 包含声明和#include "boost/filesystem.hpp"
objectfile.cpp 包含 boost::filesystem::exists(...) 的定义和用法
mainfile.cpp 包含以下代码:

#include <stdio.h>
using namespace std;

int main() {
  printf("asdf\n");
  cout <<"asdf"<<endl;
  return 0;
}

mainfile.cpp 不包含 objectfile.hpp 的 header ,但在链接阶段被链接。还链接了 boost_system 和 boost_filesystem。

问题:输出为空。在我删除 boost/filesystem.hpp 和相应的代码然后重新编译之前,没有任何输出。

我还没有测试过其他的 boost 库。也许其他人遇到过类似的问题?

Windows 7 64 位
Eclipse Juno 64 位 -std=c++11 编译器选项
Boost 1.51 多线程动态链接

更新

我用这些选项重建了 Boost 1.51:
-j8 toolset=gcc cxxflags=-std=gnu++0x variant=release optimization=speed link=static threading=multi --layout=system --prefix=boost install

现在可以了。

谢谢 Marshall Clow。提交答案,我会接受。

最佳答案

作为答案重新提交:

您是否有可能使用与您的程序不同的编译器选项构建 boost 库?具体来说,我会检查 std=c++11

关于c++11 和 boost_filesystem cout 和 printf 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12603363/

相关文章:

c++ - 减少邻接表的内存需求

c++ - 如何正确清理 C++ 中的静态类

c++ - 静态成员函数中的 `this` 类型?

c++ - 使用 XmlLite IXmlWriter (C++) 在 prolog 中创建不带编码属性的 XML

c++ - 为什么我的迭代次数少于预期?

c++ - 如何知道何时将新文件添加到 Windows 中的文件系统?

c++ - Boost.Test 检查指针是否为空

c++ - QT中窗口的排列顺序

c++ - 使用 tr1 在 C++ 中生成超出范围的随机数

c++ - 将 const char* 返回到 char* 然后更改数据