问题
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 throwserror: boost/scoped_ptr.hpp: No such file or directory
Makefile:
compile:
g++ -o gen/cavestory src/**.cc
run:
gen/cavestory
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>
.
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
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.
回答1:
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.
来源:https://stackoverflow.com/questions/22243453/mingw-g-doesnt-find-headers-in-its-own-include-directory