gpt4 book ai didi

c++ - 如果我不使用 to_string 或 from_string,为什么我需要在 boost 中编译 DateTime?

转载 作者:可可西里 更新时间:2023-11-01 16:28:27 27 4
gpt4 key购买 nike

在编译引用混合的 c++ 托管/非托管代码的 Visual Studio 2005 项目时,出现以下错误:

1>链接: fatal error LNK1104:无法打开文件“libboost_date_time-vc80-mt-1_42.lib”

我已经关注了 Getting Started Guide .相关的是这个片段:

"Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland."

我已经对“to_string”和“from_string”进行了全局搜索。这些 DateTime 方法的代码中没有出现。

documentation for the DateTime library itself ,有这个片段:

"The library has a few functions that require the creation of a library file (mostly to_string, from_string functions). Most library users can make effective use of the library WITHOUT building the library, but simply including the required headers. If the library is needed, the Jamfile in the build directory will produce a "static" library (libboost_date_time) and a "dynamic/shared" library (boost_date_time) that contains these functions."

我该如何解决这个问题?简单的解决方案是构建库或使用来自 BoostPro 的 Windows 二进制安装程序,但令我困扰的是,当根据文档我不在需要它的情况下时,需要编译的库。

另一个问题是 DateTime 文档似乎表明它“主要是 to_string,from_string)”,我的代码是否可能引用了一些其他需要创建库文件的函数?有谁知道还包括哪些其他功能?是否有自己环绕或调用 to_string 或 from_string 的函数?

我使用的唯一包含是:

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

最佳答案

只需添加:

#define BOOST_DATE_TIME_NO_LIB

在代码中包含 boost header 之前,例如:

#define BOOST_DATE_TIME_NO_LIB

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>

....
....

我希望它能有所帮助,在我的情况下它有效。

关于c++ - 如果我不使用 to_string 或 from_string,为什么我需要在 boost 中编译 DateTime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2364774/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com