【问题标题】:boost::posix_time' has not been declaredboost::posix_time' 尚未声明
【发布时间】:2013-01-31 18:32:10
【问题描述】:

当我尝试使用以下行编译代码时:(我使用的是boost 1.51gcc 4.6.3UBuntu 12.04 LTS 64 bits 中)

 #include <boost/date_time/posix_time/posix_time.hpp>

 dotFile << "// " << boost::posix_time::second_clock::local_time() << std::endl;

我收到此错误:

sources/sctg/src/main.cc: In function 'void printDot(sctg::Configuration*, std::string, std::vector<sctg::Task*>*, std::vector<sctg::Event*>*)':
sources/sctg/src/main.cc:1029:31: error: 'boost::posix_time' has not been declared

知道怎么解决吗?

【问题讨论】:

  • 尝试使用引号而不是括号:#include "boost/date_time/posix_time/posix_time.hpp"
  • 谢谢,但没用。

标签: ubuntu boost


【解决方案1】:

以下最小测试用例对我有用:

$ cat posix_time.cpp

#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>

int main()
{
    std::cout << boost::posix_time::second_clock::local_time() << std::endl;
    return 0;
}

$ g++ -Wall posix_time.cpp 
$ ./a.out 
2013-Jan-31 21:34:31
$

试试这个,看看它是否适用于您的系统。如果它失败了,那么我怀疑你的 boost 安装有问题(可能是一个空的标题)。

【讨论】:

  • 谢谢。上面的测试用例有效。我使用 Modelsim 中的“sccom”命令收到此错误。
猜你喜欢
  • 1970-01-01
  • 2021-09-25
  • 1970-01-01
  • 1970-01-01
  • 2021-03-23
  • 2011-01-22
  • 2017-05-18
  • 2017-07-05
  • 2019-09-19
相关资源
最近更新 更多