Is it possible for gcc / clang to set the library locations for different versions of C ++?

I would like to know if it is possible to install libraries in places so that gcc / clang only uses them when a particular C ++ language is used.

For example, there are specific versions of C ++ like: -std = C ++ 98, -std = C ++ 03, -std = C ++ 11, -gnu ++ 98, ...

I am asking here because I want to install boost 1.56 library for old C ++ 03 and for C ++ 11. If the object files or library files have a different ABI when using C ++ 11 or C ++ 03, so I you need to install Boost for each language version.


Additional Information:

I am using Linux Mint 17 with gcc 4.8.2 and clang 3.5.1 compilers.

I've already created boost library for gcc and one for clang. Now I would like to try some of the new features provided by the C ++ 11 language.

I read somewhere that it is unsafe to compile a library that has been compiled with another version of C ++ if it depends heavily on the C ++ standard library.

Since boost relies heavily on the C ++ standard library, I will need a different set of boost libraries for each version of C ++.

What I would like:

It would be convenient if the compiler only uses the correct boost library, depending on the std compiler option:

  • std = C ++ 03 => select boost_atomic_gcc4.8.2_C ++ 03.so
  • std = C ++ 11 => select boost_atomic_gcc4.8.2_C ++ 11.so
  • ...

We have this behavior, at least during C ++ runtime, as gcc chooses the correct execution duration based on the std option.

+3


source to share


1 answer


I think the simplest solution might be to do this from your build system. This might work if you are using GNU Make:



ifdef ELEVEN
CXXFLAGS += -std=c++11
LDFLAGS  += -L/path/to/boost-c++11
else
CXXFLAGS += -std=c++03
LDFLAGS  += -L/path/to/boost-c++03
endif

      

0


source







All Articles