使用 Boost.Math 库编译 C++ 源代码时出错
Error compiling C++ source utilizing the Boost.Math library
我正在尝试使用 G++ 编译器在一些 C++ 代码中使用 Boost Math 库中的几个函数,但我一直没有成功。这是在 macOS 上。
我从 here 下载并提取了 Boost tar.gz
并将其放入我的源文件夹中。
在我的 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
我需要使用的正确 include 语句和 G++ 命令是什么?
使用
解决
#include "/Users/[me]/[project_dir]/boost_1_63_0/boost/math/distributions/chi_squared.hpp"
和
g++ -I/Users/[me]/[project_dir]/boost_1_63_0/ main.cpp
我正在尝试使用 G++ 编译器在一些 C++ 代码中使用 Boost Math 库中的几个函数,但我一直没有成功。这是在 macOS 上。
我从 here 下载并提取了 Boost tar.gz
并将其放入我的源文件夹中。
在我的 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
我需要使用的正确 include 语句和 G++ 命令是什么?
使用
解决#include "/Users/[me]/[project_dir]/boost_1_63_0/boost/math/distributions/chi_squared.hpp"
和
g++ -I/Users/[me]/[project_dir]/boost_1_63_0/ main.cpp