ubuntu - boost::posix_time' 尚未声明

标签 ubuntu boost

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

 #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

知道怎么解决吗?

最佳答案

以下最小测试用例适用于我:

$ 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 安装有问题(可能是空 header )。

关于ubuntu - boost::posix_time' 尚未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14632702/

相关文章:

ubuntu - 插入 USB 打印机时 udev 规则不起作用

java - 在不创建 jar 文件的情况下运行 hadoop 作业

c++ - 使用 reference_wrapper 作为 condition_variable 谓词

c++ - caffe 安装 : gcc error namespace "std" has no member "isnan"

react-native - 我在 ubuntu 19 上安装 watchman 时遇到错误,有人可以给我一个解决方案吗?

boost - boost::asio tcp 套接字关闭是否阻塞?

c++ - 如何在 xpressive 中迭代命名组?

linux - 使用 message_queue 进行双向消息传递时 boost.interprocess 的问题

c++ - 如何表示地质时间? ( boost ,日期时间?)

python - 找不到文件错误 : [Errno 2] No such file or directory: 'ffmpeg'