我正在尝试使用 G++ 编译器在一些 C++ 代码中使用 Boost Math 库中的几个函数,但我没有成功。这是在 macOS 上。
tar.gz我从这里下载并提取了 Boost并将其放入我的源文件夹中。
在我尝试过的 C++ 中
#include "boost_1_63_0/boost/math/distributions/chi_squared.hpp"和
#include <boost_1_63_0/boost/math/distributions/chi_squared.hpp>.
引用版本部分有效,但该chi_squared.hpp文件包括fwd.hpp使用方括号 ( #include <...>) 表示法,这会因错误而中断我的编译In file included from main.cpp:9: ./boost_1_63_0/boost/math/distributions/chi_squared.hpp:12:10: fatal error: 'boost/math/distributions/fwd.hpp' file not found #include <boost/math/distributions/fwd.hpp>。
为了编译,我使用了各种各样的命令,但都没有成功:
g++ -L /boost_1_63_0/boost/math/distributions main.cpp
g++ -I"/boost_1_63_0/boost/math/" main.cpp
g++ -I "/boost_1_63_0/boost/math/" main.cpp
g++ main.cpp -lboost_math
我需要使用的正确包含语句和 G++ 命令是什么?