1

I need to compiler source code that contains includes like this:

#include <tr1/unordered_map> 

However my compiler (based on GCC 4.6) does not have the tr1 directory. I need to somehow tell the compiler to map <tr1/unordered_map> to <unordered_map without modifying source code of file system?

2
  • What about specifying the include directory and then doing "unordered_map"? Commented Feb 19, 2014 at 9:41
  • Like this Commented Feb 19, 2014 at 9:47

3 Answers 3

1

when you build your code, provide include directory as an argument.

-I. - For current directory as an include directory

-I tr1 - tr1 as an include directory.

-I /yourpath/ - To put any directory as include directory

Sign up to request clarification or add additional context in comments.

4 Comments

As far as I understand, the compiler will look for the name "tr1/unordered_map". So despite what directory I add to includes list, it must contain subdirector "tr1" with header "unordered_map". Unfortunately this is the problem, there is not "tr1" directory anywhere. I want to tell the complier to ignore "tr1" and just look for the header itself in all include directories.
but this should work as what you include will be searched from all the include directories also. isn't it?
Yes, but it will search for "tr1/unordered_map.h", not just "unordered_map.h". And since there is not "tr1" it won't find it. Or my assumption is wrong?
my understanding says, it should look for only unordered_map.h rather than tr1/unordered_map.h, you can give it a try!
1

Gcc headers <unordered_map> and <tr1/unordered_map> are different. One requires C++11 support turned on, the other does not. Substituting one for the other may or may not work.

Probably the easiest solution to your problem is to use the tr1 implementation from Boost.

Comments

0

A bit hacky: Go to the include directory containing unordered_map and:

ln -s . tr1 

1 Comment

Looks like it's the only choice here. Sad, I thought there is a better solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.