Find boost header files using gnu make (MinGW) on Win 7

I am using the gnu c++ compiler and make under MinGW on Win 7. I want to use several boost libraries. The problem is that the top level .hpp files are in the boost directory and they reference .hpp files in sub-directories which may reference other .hpp files either at the top level or in sibling sub-directories.

With Visual Studio I would just point to the top level directory for the headers and it would search sub-directories as needed.

Is there a way to tell gnu make to search that way or do I need to track down each sub-directory that will be used an set up a -I for it?

Just set your INCLUDE environment variable the same way. Go to the Control Panel, then "System and Security|System|Advanced Settings" and with the dialog that shows up, click "Environement Variables" and either add INCLUDE or modify an existing variable of the same name.

If cmake is struggling to find the boost installed on your platform there are 3 cache variables you can use to provide it a hint. These can either be set in your cmake script or (better) they can be set when you configure cmake on the command line.

BOOST_ROOT
BOOST_INCLUDE_DIR
BOOST_LIBRARY_DIR

If you want to "hard code" them in your script add them BEFORE your call to find Boost.

This is an example of setting it in your cmake script
SET(BOOST_ROOT "<path to boost root folder>")
SET(BOOST_INCLUDE_DIR ${BOOST_ROOT}/include)
SET(BOOST_INCLUDE_DIR ${BOOST_ROOT}/lib)

This is an example of doing the same on the command line when you first configure cmake:

evilrix, I'm using gnu make under MinGW on Win 7. not cmake. I don't see the SET(<path>) syntax in the gnu manual. Am I missing something?

jkr, I plan to compile for several platforms, so I prefer to set the INCLUDE in the makefile. I tried several variations on INCLUDE=<Path_to_boost_root> and none of them works. The other variations I tried are are commented out in the attached makefile.

The Win 7 path to the boost headers is C:\Program Files (x86)\boost\boost_1_51\boost. So the path for
boost/filesystem.hpp
should be
C:/Program Files (x86)/boost/boost_1_51
For gnu I reversed the \'s to /'s because it does not seem to process \ in a path.

The error in every case is:
$ mingw32-make
g++ -c -o hellomake.o hellomake.c
In file included from hellomake.c:4:0:
hellomake.h:9:32: fatal error: boost/filesystem.hpp: No such file or directory
#include <boost/filesystem.hpp>makefile.txthellomake.h

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Featured Post

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples. You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…

The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.