Reputation: 18183
how can I include Boost libraries (together with its includes files) in the standard search path of MinGW so that I can just do something like this;
#include <filesystem.hpp>
using boost::filesystem;
and avoiding adding -I, -l, and -L in Makefile, just like C++ standard library? (I'm using compiled boost 1.51.0 on Windows 7)
Upvotes: 4
Views: 2523
Reputation: 6118
The way I do it (for /usr/local
) I add to my globally defined CXXFLAGS
. I always use MinGW in conjunction with MSys. I changed the fstab (C:\MinGW\msys\1.0\etc\fstab
) to map C:\Users
to /home
. (That should be the default anyway.) Then I define a .profile
file in my user directory that contains my "default" CFLAGS
, CXXFLAGS
and LDFLAGS
. So in my case:
export CFLAGS=-g -Wall -I/usr/local/include
export CXXFLAGS=-g -Wall -I/usr/local/include
export LDFLAGS=/usr/local/lib
In the makefile, I then only extend the variables as needed:
LDFLAGS += -lawsomelib
This works like a charm and has the advantage that I can locally redefine CXXFLAGS
in special cases. Basically you should assume in a makefile that the variables CC, CXX, CXXFLAGS, CFLAGS and LDFLAGS are already defined and contain useful stuff. This is the portable and sort of standard way to do it.
(NOTE: /usr/local
is not used as standard include location in vanilla MinGW + MSys.)
Upvotes: 2
Reputation: 11756
By default GCC looks for C_INCLUDE_PATH and CPP_INCLUDE_PATH environment variables. Instead of doing -I, you can add the following to your .bashrc:
export CPP_INCLUDE_PATH=/path/to/your/boost/header
Upvotes: 1