1
votes

About a week ago I moved from Windows and Visual Studio to Mac and Xcode. I want to be able to work on my project on Mac, so I decided to port it.

First of all I need test to work on Mac and Google provides instructions about how to do so. After I build test with my Xcode, I can see three files in the output directory: test.framework, libgtest_main.a and libgtest.a.

Documentation says I need to link test.framework with my project. So, I create new console app project and link it with test.framework file. Unfortunately my build fails with about 70+ issues. After I link librettist.a to my project, it fails with only 2 issues. Here they are:

Undefined symbols for architecture x86_64:
"testing::internal::EqFailure(char const*, char const*, std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, bool)", referenced from: testing::AssertionResult testing::internal::CmpHelperEQ(char const*, char const*, int const&, int const&) in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

As I understood, linker cannot resolve symbols. If I link my project with libgtest_main.a it changes nothing and this error is still here. So, how can I fix it?

1
I have the same problem. I am trying to use gtest on Mac OSX from QtCreator.robert

1 Answers

0
votes

I had the same problem and was unable to figure out why this isn't being created. It does work fine on some 32 bit code, so I'm equally puzzled.

That said, the sample in the gtest package has the following comment:

EXPECT_EQ(expected, actual) is the same as EXPECT_TRUE((expected) == (actual)) except that it will print both the expected value and the actual value when the assertion fails. This is very helpful for debugging. Therefore in this case EXPECT_EQ is preferred.

and the same is true for ASSERT_EQ and ASSERT_TRUE. So if you make the substitution, you lose some information in the case of failure, but at least you can use it.