11

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

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.

tjtoml
  • 331
  • 2
  • 5
  • 13
  • 2
    Your mingw might be getting shadowed. – Rapptz Mar 07 '14 at 06:49
  • 1
    Try "which g++" in the make file to figure out which is getting invoked. By the way, you shouldn't be hard-coding "g++" in your Makefiles. This is bad form. Please see: https://sites.google.com/site/michaelsafyan/software-engineering/how-to-write-a-makefile – Michael Aaron Safyan Mar 07 '14 at 06:51
  • Is the current install location the same as the previous one that worked? You may still be looking in the old folders for the files. A quick, painless check would be to copy the boost folder from the current install into the include folder of the previous install (assuming of course, that the answer to my first question was no) – enhzflep Mar 07 '14 at 06:52
  • @MichaelAaronSafyan Syntax for that? – tjtoml Mar 07 '14 at 06:55
  • @enhzflep Yes, both installations were located at C:\MinGW\. When installing the update I cleaned out the MinGw directory completely. – tjtoml Mar 07 '14 at 06:57
  • It might be helpful to use Process Monitor (available from the MS web site) to see where MinGW is looking when it fails to find the files in question. – Harry Johnston Mar 07 '14 at 07:08
  • 4
    Create an empty `empty.c` file, then issue the command: `gcc -v empty.c`. Paste the output into your question. Included in the spew will be the directories that the compiler will search for include file in. Assuming you've installed the nuwen distro into `c:\mingw`, `scoped_ptr.hpp` should be in `c:\mingw\include\boost\` – Michael Burr Mar 07 '14 at 07:19
  • @HarryJohnston I downloaded and ran it, but the output is really complex. I managed to find the make invocation, but there are so many instances of programs in the toolchain I don't know where to look. – tjtoml Mar 07 '14 at 11:23
  • If you filtered by the name of the include file you should see just the times when the program tries to open that file, which should show which directory or directories it is looking for it in. (Obviously Michael's solution is better in this situation!) – Harry Johnston Mar 08 '14 at 00:01

1 Answers1

9

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.

tjtoml
  • 331
  • 2
  • 5
  • 13
  • Ah-ha - I've been running the `set_distro_paths.bat` script to set the path to MinGW's executables. Little did I know it also adds (or sets) a couple directories, such as `c:\mingw\include` to the `C_INCLUDE_PATH` and `CPLUS_INCLUDE_PATH` environment variables. That's what gets boost and friends. I thought that `set_distro_paths.bat` only set the path. – Michael Burr Mar 07 '14 at 09:31
  • Also, it's interesting/weird that using the `-I` option didn't get things working for you. Maybe you specified `-I c:\mingw\include\boost` instead of just `-I c:\mingw\include`? – Michael Burr Mar 07 '14 at 09:34
  • I tried both. I'm now slamming my head against the linker not being able to locate SDL.lib and SDLMain.lib. I'm getting undefined reference to every SDL_* call – tjtoml Mar 07 '14 at 11:12
  • You might want to post the `-v` output in your question. Also, keep in mind that since release 11.0, nuwen's MinGW is x64 native (it defaults to building x64 targets - I think that it doesn't even support the `-m32` option to build a 32-bit target), so make sure any libraries you're adding to your build are also x64. If you've installed 32-bit SDL libs that could be a reason for undefined references, since some name mangling rules for x86 and x64 are different. – Michael Burr Mar 07 '14 at 17:28