Reputation: 1745
I have a C++11 project that uses Google Test, and it builds great in Linux. On a Mac, I am having more difficulty integrating it into my code base. The issue seems to be that while my code uses C++11, the Google code uses TR1. As a result, TR data structures like enum
and unordered_set
are included differently.
The Google Test samples build and run perfectly as provided. The samples also build just fine if I use clang++ instead of g++. (My code works only on clang++, so I use that to build.) Finally, Google's code also builds and runs if I use -std=c++11
.
However, Google test does not build using clang++ on my mac if I use -stdlib=libc++
. It reports that it cannot find tr1/tuple, which, of course, is true. This is a problem, because my code does not build if I use -stdlib=libstdc++
(or no stdlib
argument).
Of course, I could switch all of my code over to the older standard. This, however, is extremely yuck. Is there a way to make these code bases live happily side-by-side on the Mac?
My code builds happily with Google test using g++ 4.6.3 on an Ubuntu 12.04 computer. The mac is running OSX 10.8.3. It's running g++ 4.2.1 and clang 4.2++.
Thanks for any help, David
PS: I am somewhat new to C++, so forgive me if this is a foolish question.
Edit: Changed "OS/X" to "OSX." (Yes, I am that old.)
Upvotes: 2
Views: 1152
Reputation: 173
You can instruct Google test to use its own implementation of tr1::tuple
In cmake I use the following line to compile with "old" compilers:
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
I'm sure you can add it to your build system, it's a simple preprocessor definition.
You can look at include/gtest/internal/gtest-port.h for more options. GTEST_USE_OWN_TR1_TUPLE may be useful. Most of the parameters are correct with default values.
Upvotes: 1