user2678627
user2678627

Reputation: 51

Google Test and XCode 4.6

Problem with google test in XCode 4.6.3

Hello all,

I have integrated google tests into my XCode project, and basic command line tool for unit testing seems to work fine (guest.framework added, DYLD_LIBRRY_PATH set correctly).

However, as soon as I add to object fixture EXPECT_EQ(0, Object.PublicMember) type test, I get following linker error.

Ld /Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug/UnitTest normal x86_64
cd /Users/rinkevic/Development/VeloxChemX
setenv MACOSX_DEPLOYMENT_TARGET 10.8
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug -F/Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug -F/Users/rinkevic/Development/Frameworks -F/Users/rinkevic/Development/VeloxChemX/../../Library/Frameworks -F/Users/rinkevic/Development/VeloxChemX/../Frameworks -filelist /Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Intermediates/VeloxChemX.build/Debug/UnitTest.build/Objects-normal/x86_64/UnitTest.LinkFileList -mmacosx-version-min=10.8 -stdlib=libc++ -framework gtest -framework OpenCL -o /Users/rinkevic/Library/Developer/Xcode/DerivedData/VeloxChemX-hbmvfkmcscchsvebxpaefvzmkvdp/Build/Products/Debug/UnitTest


Undefined symbols for architecture x86_64:
"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<int, int>(char const*, char const*, int const&, int const&) in TestCartMom.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any suggestion what I am doing wrong?

Upvotes: 5

Views: 1378

Answers (4)

dev
dev

Reputation: 2200

By default General.xcconfig points to 10.4 SDK, changing it to 10.10 fixed issue for me

Upvotes: 0

Peter N. Steinmetz
Peter N. Steinmetz

Reputation: 1252

Another solution is outlined here: http://dennycd.me/google-test-xcode-mac-osx/ which brings some sanity to the situation by not using a framework but instead installing into /usr/local.

Remember that the libs must be renamed to start with 'lib', for example libgtest.a.

Also remember that you must link to both libgtest.a and libgtest_main.a. Without the latter, you will get a complaint about missing the main method.

The same comments regarding the c++ dialect and the library are applicable, but I found it very hard to control these while producing the framework and trying to link to that.

Upvotes: 1

Dongle Su
Dongle Su

Reputation: 21

It's because the build options of your unit test project is different with the gtest project. Make sure the build options such as "Apple LLVM - Language" & "Apple LLVM - Language - C++" are all the same.

Upvotes: 2

Pedro Soares
Pedro Soares

Reputation: 1195

I had the same problem.

Choose libstdc++ in both projects.

Upvotes: 6

Related Questions