MinGW g ++在其自己的包含目录中找不到标头 [英] MinGW g++ doesn't find headers in its own include directory
问题描述
因此,我最近通过最新版本的 nuwen的MinGW发行版安装了MinGW,该发行版包括boost C ++库.具体来说,我是在boost库提供的scoped_ptr之后.但是,当我尝试在我的标头中包含scoped_ptr( #include< boost/scoped_ptr.hpp>
)时,编译器将抛出错误:boost/scoped_ptr.hpp:没有这样的文件或目录
So I recently installed MinGW via the latest version of nuwen's MinGW distribution that includes the boost C++ libraries. Specifically, I was after the scoped_ptr that the boost library provides. However, when I try to include the scoped_ptr (#include <boost/scoped_ptr.hpp>
) in my header, the compiler throws
error: boost/scoped_ptr.hpp: No such file or directory
Makefile:
compile:
g++ -o gen/cavestory src/**.cc
run:
gen/cavestory
此外,我在SDL/**下的MinGW的include目录中添加了SDL的反向版本.我已经检查了所有的头文件,并且编译器在我的 include SDL/SDL.h>
上抛出了类似的错误.
Also, I added a back version of SDL to MinGW's include directory under SDL/**. All of the header files are there, I've checked, and the compiler throws a similar error on my include SDL/SDL.h>
.
我尝试过的事情:
我的include语句中<>
和"
的每个变体
删除 .h
和 .hpp
设置编译器标志以使用 g ++ -I
Things I've tried:
Every variation of <>
and ""
in my include statements
Removing the .h
and .hpp
Setting the compiler flags to specifically search the directories containing the headers with g++ -I
此代码是使用MinGW的早期版本进行编译的,MinGw发行版的作者特别指出,他将g ++编译器选项更改为默认为C ++ 11,因此,我认为这很可能与那.不过,我的google-fu并没有产生结果.
This code was compiling with an earlier version of MinGW, and the author of the MinGw distrobution specifically states that he changed the g++ compiler options to default to C++11, so I think it's very likely that it's something to do with that. My google-fu has not yeilded results, though.
推荐答案
我想到的解决方案是:根据以上迈克尔·伯尔(Michael Burr)的评论,我使用详细标志运行编译器.由于某些原因,搜索到的包含目录不在MinGw根目录中,而是埋在 lib
目录中.我希望可以使用其中一种安装脚本来解决此问题,但是我没有正确运行它,或者它在我的系统上不起作用.在我的机器上,我需要在其中添加相关文件的目录
Solution I came up with: based on Michael Burr's comment above I ran the compiler with the verbose flag. For some reason, the include directory that is searched is not located in the MinGw root directory, but buried in the lib
directory. I expect that this was intended to be fixed with one of the installation scripts, but I either didn't run it correctly or it didn't work on my system. The directory where I needed to add the relevant files is, on my machine,
C:\ MinGW \ lib \ gcc \ x86_64-w64-mingw32 \ 4.8.2 \ include
这是一个快速修复程序.我确信有更好的方法,但是这使我起步并运行得最快.
This is a quick-and-dirty fix. I'm sure that there's a better way, but this got me up and running the quickest.
这篇关于MinGW g ++在其自己的包含目录中找不到标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!