Running on an older version of rhel with an fairly old version of boost in /usr/include/boost. Installed a more modern version of boost and added the appropriate -I option to g++ so that it almost always goes to the new directory for boost headers. The problem is that a lot of the code base was written years ago for older versions of boost and includes headers that don't exist in a more modern boost. In this case, cpp happily includes the header from /usr/include/boost. What's the best way to avoid this? I'd rather not change #include <boost/file.hpp> to explicitly point to a different place unless I have to and am more than happy to clean up code that relied on extinct headers if I only knew what they were. And this could be an ongoing problem as some of the programmers working on the project might by habit include extinct headers, so simply checking once isn't enough.
1 Answer
Instead of trying to change where the code looks for the includes, or changing the makefile to include some other directory, how about changing the contents of /usr/include/boost so that it points to the new stuff?
Here's what I'd try to do:
- Rename
/usr/include/boostto something else, perhaps/usr/include/boost-old - Create a symbolic link that points
/usr/include/boost->/usr/boost/include/boost-old - You can now test this config by compiling your app. It should inlcude the old Boost libraries.
- Install the new Boost libraries to a new directory, say
/usr/include/boost-new - Change the suymbolic link to point to the new libraries
/usr/include/boost->/usr/include/boost-new
gcc -Ifakedir ...