Solved

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

Posted on 2013-10-26
11
112 Views
Last Modified: 2016-05-09
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?

Thank you!
0
Comment
Question by:anAppBuilder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
11 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39603889
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.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 500 total points
ID: 39603952
BTW, alternatively you also can specify 'INCLUDE' in your Makefile, i.e.

INCLUDE=<Path_to_boost_root>
0
 
LVL 40

Expert Comment

by:evilrix
ID: 39604100
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:

cmake . -DBOOST_ROOT:string="<path to boost root folder>" -D${BOOST_ROOT}/include -D${BOOST_ROOT}/lib

Personally, I would go with the latter. If you hard code it then it'll work on your dev machine but will possibly fail on others.

You want to avoid setting any other variables since these should be set by the FindBoost module.

More info:

http://www.cmake.org/cmake/help/v2.8.12/cmake.html#module:FindBoost
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:anAppBuilder
ID: 39607334
Thank you jkr and evilrix.  

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.txt
hellomake.h
0
 
LVL 86

Expert Comment

by:jkr
ID: 39607339
Your path contains spaces, so try to quote it, e.g.

INCLUDE="C:/Program Files (x86)/boost/boost_1_51"
0
 

Author Comment

by:anAppBuilder
ID: 39607372
Thank you, jkr.  That did not change anything.

Note that commented out in the makefile I show the other variations I have tried that did not work.
makefile.txt
0
 

Author Comment

by:anAppBuilder
ID: 39636402
I finally solved the problem.  I had to separate my link from my compiles and put a -I in my compiles.

I then encountered a second problem in my linking:
undefined reference to `boost::system::...

Open in new window

 That was caused because boost/filesystem depends on boost/system, so I had to add the boost/system library to my link.

I've attached the entire working set of test code.
test.zip
0
 

Author Comment

by:anAppBuilder
ID: 41578854
evilrix, you also posted comments.  Shouldn't you give yourself some points?  

And my apologies.  I thought I closed this long ago splitting the points between you and jkr
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ to C# code conversion issue 4 134
convert char array to number in c 5 93
c++ syntax question 9 67
Beginner to Unreal Engine 4 5 120
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question