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?
GTest is objected oriented tool and C language isn't! from GTest website gmock_for_dummies.md so you will use only macros like expect_equal, expect_bigger_than and so on... I would like to suggest you tool CMocka (or some other C unit testing tools).
Add a Google Test project in Visual Studio 2019In Solution Explorer, right-click on the solution node and choose Add > New Project. Set Language to C++ and type test in the search box. From the results list, choose Google Test Project. Give the test project a name and choose OK.
gtest-parallel is a script that executes Google Test binaries in parallel, providing good speedup for single-threaded tests (on multi-core machines) and tests that do not run at 100% CPU (on single- or multi-core machines).
I had the same problem.
Choose libstdc++ in both projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With