Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtest fails to link on mac with the default compiler

When I am trying to build some code which uses GTest, on my mac with the latest clang, it fails at linking with

Undefined symbols for architecture x86_64:
  "testing::Message::Message()", referenced from:
      parse::testing::DiffWithGoldenFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in v8test_helper.o
  "testing::internal::PrintStringTo(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*)", referenced from:
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > testing::PrintToString<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in v8sandbox_test.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > testing::PrintToString<char const*>(char const* const&) in v8sandbox_test.o
      std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > testing::PrintToString<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in v8test_helper.o
  "testing::internal::EqFailure(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
      testing::AssertionResult testing::internal::CmpHelperEQ<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in v8sandbox_test.o

...

Any one have ideas on fixing it?

like image 643
sheki Avatar asked Mar 21 '23 21:03

sheki


1 Answers

Solved it by compiling Gtest with the flags

./configure CXX="clang++ -std=c++11 -stdlib=libc++" && make
like image 134
sheki Avatar answered Mar 23 '23 09:03

sheki