尝试使用生成文件编译程序时"fatal error: boost/regex.hpp: No such file or directory" C++

"fatal error: boost/regex.hpp: No such file or directory" when trying to compile C++ program using a makefile

本文关键字:regex boost hpp such C++ directory or file No error 文件      更新时间:2023-10-16

我正在尝试编译一个名为"物种"的开源软件在文本中识别分类学提及。我在MacOS

我下载了源代码(可以在此处找到(,移至目录中,并使用命令make进行编译。这是返回的错误:

g++ -fpic -pthread -Wall -O3 -o organisms organisms.cxx -lm -lboost_regex
In file included from batch_tagger.h:5:0,
                 from organisms.cxx:3:
tagger.h:7:27: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
make: *** [organisms] Error 1

我使用brew install boost安装了 C Boost Library ,并再次尝试了上述步骤(它不起作用(。

我尝试将Boost目录列入包含源代码的目录(它不起作用(。

有任何建议/帮助?

您需要告诉编译器在哪里可以找到Boost标头。

您需要使用Include路径选项来指定可以在何处找到可以找到升压标头的位置,请使用-I/path/to/boost/include

然后使用来自代码的#include <boost/regex.hpp>包含文件。