-5

我在我的 Mac 上成功安装了 boost,但我无法将它包含在我的代码中。

安装

brew install boost

代码

#include <boost/asio.hpp>
#include <regex>
#include <iostream>
int main() {
    std::string server = "www.stroustrup.com";
    enter code here
    std::string request = "GET http://" + server + "/C++.html 
HTTP/1.0\r\nHost: " + server + "\r\n\r\n";
    boost::asio::ip::tcp::iostream s{server, "http"};
    s << request;
    std::regex pat{R"((http://)?www([./#\+-]\w*)+)"};
    std::smatch m;
    for (std::string l; getline(s, l);)
        if (std::regex_search(l, m, pat))
            std::cout << m[0] << "\n";
}
4

1 回答 1

1

即使您确实安装了 boost,您仍然需要将标头添加到您的应用程序中。

转到您的目标属性 -> 构建设置 -> 标题搜索路径并添加/usr/local/include. 那就是应该安装IIRC的地方。

于 2018-11-08T21:50:34.023 回答