Cygwin:“boost / filesystem.hpp:没有这样的文件或目录编译终止。”

时间:2017-02-24 20:03:42

标签: makefile cygwin

当我在“makefile”上使用Cygwin时出现此错误:

"boost/filesystem.hpp: No such file or directory compilation terminated."

这就是“makefile”中的所有内容:

mnisten: src/main.cpp g++ -Wall -O2 -lboost_filesystem-mt -std=c++0x -o mnisten src/main.cpp

在“main.cpp”文件中,这是错误消息所指的代码行:

#include <boost/filesystem.hpp>

首先,我尝试将“boost”文件夹(包含“filesystem.hpp”)放在“src”文件夹中,但错误消息未更改,我仍然收到相同的错误消息。

然后我将“main.cpp”中的“include”代码更改为: #include <filesystem.hpp>

我还将“filesystem.hpp”文件复制到“src”文件夹的根目录中,这令人惊讶。我收到了一个新错误,但我已经超越了“包含”部分。

我觉得很困惑的是,当文件在文件夹中时我收到错误,但是当它位于“src”文件夹的根目录下时它会起作用。

当文件在“boost”文件夹中时,有关如何让它工作的任何建议吗?

(我下载了“filesystem.hpp”,因为它没有包括在内)

2 个答案:

答案 0 :(得分:1)

要查找包含给定文件的cygwin软件包,您可以使用cygcheck -p

$ cygcheck -p boost/filesystem.hpp
Found 6 matches for boost/filesystem.hpp
libboost-devel-1.60.0-1 - libboost-devel: Boost C++ libraries (installed binaries and support files)
libboost-devel-1.60.0-2 - libboost-devel: Boost C++ libraries (installed binaries and support files)
mingw64-i686-boost-1.60.0-1 - mingw64-i686-boost: Boost C++ libraries for Win32 toolchain (installed binaries and support files)
mingw64-i686-boost-1.60.0-2 - mingw64-i686-boost: Boost C++ libraries for Win32 toolchain (installed binaries and support files)
mingw64-x86_64-boost-1.60.0-1 - mingw64-x86_64-boost: Boost C++ libraries for Win64 toolchain (installed binaries and support files)
mingw64-x86_64-boost-1.60.0-2 - mingw64-x86_64-boost: Boost C++ libraries for Win64 toolchain (installed binaries and support files)

因此您需要安装libboost-devel,因为您没有为mingw64进行交叉编译 类似于

$ cygcheck -p opencv/cv.hpp
Found 1 matches for opencv/cv.hpp
libopencv-devel-2.4.11-1 - libopencv-devel: Real-time computer vision library (development) (installed binaries and support files)

答案 1 :(得分:0)

可能您的系统中没有安装任何 boost。我收到此错误并通过安装解决。

sudo apt-get install libboost-all-dev