在Mac上的VS Code中包含Boost(未找到文件)



我在编译这个文件(hello.cc)时遇到一个错误:

#include <boost/asio.hpp>
int main() {
return 0;
}

执行完:g++ -o hello.o hello.cc.
我看到:fatal error: 'boost/asio.hpp' file not found.

…即使我(编辑:认为我)安装了boost使用brew在位置:/opt/homebrew/Cellar/boost/1.81.0_1(编辑:但事实证明,它可以更好地考虑安装在/opt/homebrew/Cellar/boost/1.81.0_1/include)

…并将/opt/homebrew/Cellar/boost/1.81.0_1添加到C_Cpp > Default: Include PathVisual Studio Code设置

使用g++ -o hello.o -I /opt/homebrew/Cellar/boost/1.81.0_1 hello.cc编译得到相同的结果。

如何解决这个问题?

编辑:解决。

为了后代:我通过编译g++ -o hello.o -I /opt/homebrew/Cellar/boost/1.81.0_1/include hello.cc

修复了这个问题。这是有意义的,因为boost/asio.hpp/opt/homebrew/Cellar/boost/1.81.0_1/include中找到。

最新更新