【问题标题】:Linking ASIO to a project without boost in Visual Studio在 Visual Studio 中将 ASIO 链接到项目而无需提升
【发布时间】:2016-02-07 01:00:14
【问题描述】:

我正在尝试将 asio 用于 Visual Studio 中的项目而无需提升。

我已通过将asio\include 添加到项目属性中的Additional Include Directories 来添加标题。这使我的项目可以看到标题,并且智能感知可以正确找到所有对象。到目前为止,一切顺利。

但是,当我尝试编译时,我得到了找不到 boost headers 的错误,例如:

cannot open source file "boost/date_time/posix_time/posix_time_types.hpp" example-udpreceiver c:\Users\me\project\libs\asio-1.10.6\include\asio\deadline_timer.hpp

cannot open source file "boost/regex/v4/match_flags.hpp" example-udpreceiver c:\Users\me\project\libs\asio-1.10.6\include\asio\detail\regex_fwd.hpp

我的印象是可以在没有 boost 的情况下使用 asio -- 我需要做什么才能让 asio 与我的项目一起编译?

谢谢!

【问题讨论】:

  • 你是从这里下载asio的吗? think-async.com
  • 我确实从那里下载了它。

标签: c++ boost visual-studio-2015 boost-asio


【解决方案1】:

您需要定义ASIO_STANDALONE 宏以使asio 在独立模式下正常工作。

【讨论】:

  • 应该将其设置为特别的任何内容,还是仅#define ASIO_STANDALONE 就足够了?
  • 我建议将定义添加到Configuration Properties > C/C++ > Preprocessor > Preprocessor Defintions(或CMake的add_definitions)。否则,您需要注意在每次包含 asio 之前定义宏。可能只设置宏就足够了。
  • 谢谢;这有助于解决提升依赖关系!仍然存在D8049 -- cannot execute c1xx.dll: command line is too long to fit in debug record 类型的奇怪错误,但目前尚不清楚这是否与包含 asio 有关(目前)。
  • 我在一个小例子中测试了独立版本:pastebin.com/LfQvg8pB。我怀疑您的错误与 asio 有任何关系。
  • 嗯,所以当我尝试将其实际添加到项目中时,我收到错误:error C2039: 'CreateEvent': is not a member of 'global namespace''。任何想法是什么原因造成的? ASIO_STANDALONE_WIN32_WINNT=0x0501 都在预处理器中定义。
猜你喜欢
  • 2017-04-20
  • 2014-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-19
  • 2018-01-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多