Boost date_time cpp 文件丢失

Posted

技术标签:

【中文标题】Boost date_time cpp 文件丢失【英文标题】:Boost date_time cpp files missing 【发布时间】:2011-07-23 10:38:35 【问题描述】:

我正在尝试编译 this program,但在网上找不到以下文件:

#include <libs/date_time/src/posix_time/posix_time_types.cpp>
#include <libs/date_time/src/gregorian/date_generators.cpp>

speed_test\speed_test.cpp|42|error: boost/date_time/posix_time/posix_time_types.cpp: No such file or directory|
speed_test\speed_test.cpp|43|error: boost/date_time/gregorian/date_generators.cpp: No such file or directory|
speed_test\MruCache.h||In member function 'void MruCache<key_type, value_type>::__insert_item(key_type, value_type)':|
speed_test\MruCache.h|70|error: 'ptrItr' was not declared in this scope|
speed_test\MruCache.h|71|error: expected primary-expression before ')' token|
speed_test\MruCache.h|71|error: expected ';' before 'mapOfListIteratorPtr'|
speed_test\MruCache.h|87|error: expected type-specifier|
speed_test\MruCache.h|87|error: expected ';'|
speed_test\MruCache.h||In member function 'value_type MruCache<key_type, value_type>::__find_item(key_type)':|
speed_test\MruCache.h|104|error: 'ptrItr' was not declared in this scope|
speed_test\MruCache.h|105|error: expected primary-expression before ')' token|
speed_test\MruCache.h|105|error: expected ';' before 'mapOfListIteratorPtr'|
C:\Dev-Cpp\project2\speed_test\MruCache.h||In member function 'virtual void MruCache<key_type, value_type>::__clear()':|
speed_test\MruCache.h|119|error: expected ';' before 'i'|
speed_test\MruCache.h|120|error: 'i' was not declared in this scope|
speed_test\MruCache.h|123|error: 'pItr' was not declared in this scope|
speed_test\MruCache.h|123|error: expected primary-expression before ')' token|
speed_test\MruCache.h|123|error: expected ';' before 'ptrItr'|
speed_test\mru.h|142|error: type/value mismatch at argument 1 in template parameter list for 'template<class _T1, class _T2> struct std::pair'|
speed_test\mru.h|142|error:   expected a type, got 'boost::unordered_map::iterator'|
speed_test\mru.h|143|error: invalid type in declaration before '=' token|
speed_test\speed_test.cpp||In function 'int main(int, char**)':|
speed_test\speed_test.cpp|178|error: 'ihash' was not declared in this scope|
speed_test\speed_test.cpp|178|error: template argument 3 is invalid|
speed_test\speed_test.cpp|178|error: invalid type in declaration before ';' token|
speed_test\speed_test.cpp|186|error: request for member 'clear' in 'tiles1_2', which is of non-class type 'int'|
speed_test\speed_test.cpp|191|error: no match for 'operator[]' in 'tiles1_2[keys.std::vector<T, Allocator>::operator[] [with _Tp = tile_id, _Alloc = std::allocator<tile_id>](((unsigned int)i))]'|
speed_test\speed_test.cpp|202|error: no match for 'operator[]' in 'tiles1_2[keys.std::vector<T, Allocator>::operator[] [with _Tp = tile_id, _Alloc = std::allocator<tile_id>](((unsigned int)i))]'|
speed_test\speed_test.cpp|433|error: request for member 'find' in 'tiles1_2', which is of non-class type 'int'|
speed_test\speed_test.cpp|560|error: request for member 'clear' in 'tiles1_2', which is of non-class type 'int'|
speed_test\mru.h|241|instantiated from 'Value& mru::list<Key, Value>::operator[](const Key&) [with Key = tile_id, Value = boost::shared_ptr<test>]'|
speed_test\speed_test.cpp|340|instantiated from here|
speed_test\mru.h|143|error: dependent-name 'boost::unordered_map::value_type' is parsed as a non-type, but instantiation yields a type|
speed_test\mru.h|143|note: say 'typename boost::unordered_map::value_type' if a type is meant|
speed_test\mru.h|241|instantiated from 'Value& mru::list<Key, Value>::operator[](const Key&) [with Key = tile_id, Value = boost::shared_ptr<test>]'|
speed_test\speed_test.cpp|340|instantiated from here|
speed_test\mru.h|143|warning: unused variable 'p'|
||=== Build finished: 27 errors, 1 warnings ===|

【问题讨论】:

【参考方案1】:

您似乎在#include 指令中有一些错误,boost 库通常包含为

#include <boost/whatever.hpp>

#include <boost/module/header.hpp>

或者,如果 boost 库没有安装到您的包含路径并且它存在于当前目录中:

#include "boost_1_46_1/boost/..."

文件名规则如上所述

阅读文档了解更多信息

【讨论】:

不...我确实搜索了这些文件,但我的硬盘上没有它们。 @lost_with_coding 现在这真的很奇怪。一个愚蠢的问题,但我不得不问,你确定你一开始就安装了boost吗?!而不是相同的一些衍生物? DateTime 存在于默认的 boost 安装中,它是一个仅头文件的库。 是的,我有带有头文件的 date_time 文件夹,但没有 .cpp 文件。有点奇怪。我确实找到了头文件 posix_time_types.h date_generators.h @lost_with_coding :你为什么要尝试#include .cpp 文件呢?只需构建 Boost.DateTime 并正常包含其标题。 @lost_with_coding,ildjam 是对的,您应该使用 .hpp 来包含标题,而不是那些 .cpp 文件(如果它们存在)。 .cpp 文件仅存在于某些库中,我不认为 datetime 是其中之一。请记住,大多数 boost 库都是仅标头的。

以上是关于Boost date_time cpp 文件丢失的主要内容,如果未能解决你的问题,请参考以下文章

boost::thread demo

boost 日期时间计算

C ++ boost nuget无法打开文件Visual Studio 2015

Boost Multiindex:示例在 cpp 文件中编译,但不在标头中

使用带有 inline-c-cpp 的 C++ 库 (boost)

boost datetime