【问题标题】:error: C1083: Cannot open include file: 'boost/asio.hpp': No such file or directory错误:C1083:无法打开包含文件:'boost/asio.hpp':没有这样的文件或目录
【发布时间】:2019-10-21 10:26:30
【问题描述】:

我在 windows 7 中使用 Qt creator。当我使用 32 位 VC 2010 编译器编译我的项目时,出现错误: 错误:C1083:无法打开包含文件:'boost/asio.hpp':没有这样的文件或 目录

.pro:

LIBS += -L"D:/MDT/boost_1_71_0/libs" - 
   llibboost_date_time-vc141-mt-x32-1_71 \
    - 
    L"D:/MDT/boost_1_71_0/libs" - 
    llibboost_regex-vc141-mt-x32-1_71 \

main.cpp

   #include <boost/asio.hpp>

【问题讨论】:

    标签: c++ qt-creator


    【解决方案1】:

    您需要告诉编译器在哪里查找包含文件。

    添加

    INCLUDEPATH += &lt;path_to_boost_dir&gt;

    到 .pro 文件。在你的情况下,它可能是

    INCLUDEPATH += D:/MDT/boost_1_71_0/

    【讨论】:

    • 我已经使用了你的方法并且我的问题已经解决了,但是又发生了:asio.hpp:20: error: C1083: Cannot open include file: 'boost/asio/associated_allocator.hpp': No such file或目录
    • @williamYUANG,你是不是碰巧把它包括在#include "boost/asio/associated_allocator.hpp"而不是#include &lt;boost/asio/associated_allocator.hpp&gt;?如果不是这种情况,请检查该文件是否确实存在。例如,对我来说,它位于“C:\Users\Username\Documents\Boost\boost\asio\associated_allocator.hpp”中。在这种情况下,INCLUDEPATH 应该是 C:\Users\Username\Documents\Boost,并且 include 指令应该看起来像 #include &lt;boost/asio/associated_allocator.hpp&gt;
    • 我的是#include 并且所有文件都存在于boost库中。我没有更改 boost 库中的任何内容。
    【解决方案2】:

    您需要使用INCLUDEPATH 指定库头所在的位置,因此您需要在.pro 文件中添加:INCLUDEPATH += D:/MDT/boost_1_71_0/ 并运行qmake。

    msvc141(在 boost 库名称中)代表 Visual Studio 2017,它与您使用的 Visual Studio 2010 不兼容,因此您很可能会遇到链接器错误或奇怪的运行时崩溃。要解决您需要下载使用 Visual Studio 2010 构建的 boost 的问题,请在下载 boost 的网站上查找 msvc10(32 位或 64 位,具体取决于您的需要)并获取该版本。

    【讨论】:

    • 我已经使用了你的方法并且我的问题已经解决了,但是又发生了:asio.hpp:20: error: C1083: Cannot open include file: 'boost/asio/associated_allocator.hpp': No such file或目录
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    相关资源
    最近更新 更多