The hint includes a path to increase in one place only in g ++

I am working on a code base that uses boost libraries. But I recently had problems creating a database on a new user machine. I was able to solve the problem as follows. Here's what the build system looks like:

/root /SubModules_with_Makefiles_and_Code /thirdparty/boost 

The submodule code will refer to the forced material, for example (for example):

 #include <boost/property_tree/ptree.hpp> 

And the makefile subcomplex will create code such as this (for example):

 g++ -c -o code.o code.cpp -I/root/thirdparty/boost 

Our third-party boost library is version 1.37. However, some modules began to use later versions of boost. This problem was masked because the machines on which these modules were created contain boost 1.41 installed in / usr / include / boost.

The problem arose because the new user machine did not have a 1.41 upgrade installed in / usr / include. Ideally, I would like g ++ to look for promotion in a third-party directory and nowhere else. Thus, we can more precisely control how the code base is created.

-I <dir> puts <dir> before the system will turn on during the search, but still the system includes it, and that is where later versions of boost can be installed depending on the machine. I can stifle a look at the system, but that would be a real pain.

In any case, a sensible way to do this, except by replacing:

 #include <boost/something.hpp> 

to

 #include <thirdparty/boost/something.hpp> 

? If this helps, I use gnu make 3.81 and g ++ 4.4.5 on redhat linux.

+4
source share
2 answers

Look at the 'include path' (-I) command line option. You can set where it searches for included files. Documentation here

0
source

You can take a look at section 2.3 of the gcc manual: http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

The compiler switch you're looking for is likely to be

 -nostdinc 

But better take a look at yourself.

EDIT: oop, I just saw that you DO NOT want to disable the default search path - in this case, just use the -I switch:

You can add the -Idir command line option to this list. All directories named -I are scanned from left to right in front of the default directories.

0
source

All Articles