未能在macos上包含boost

  • 本文关键字:包含 boost macos c++
  • 更新时间 :
  • 英文 :


我成功地在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.0rnHost: " + server + "rnrn";
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";
}

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

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

最新更新