problem about googletest-Collection of common programming errors


  • gnash117
    c++ testing build linker googletest
    I am currently trying to build some test code that uses Google C++ Test framework but I keep getting an error stating ld: warning: in /usr/local/lib/libgtest.dylib, file was built for unsupported file format which is not the architecture being linked (i386)I have tried to make the issue as simple as possible:I have a main function cmtest.cc#include /** Main entry point */ int main(int argc, char**argv, char**envArg) {testing::InitGoogleTest(&argc, argv);return(RUN_ALL_TESTS()); }really basic test code CrazyTest.cc#include TEST(CrazyTest, one) {EXPECT_EQ(2, 2); }I use the following commands to build gtest and my test code.g++ -o CrazyTest.o -c -Wall -Werror=non-virtual-dtor -pipe -std=c++98 -fno-rtti -fno-exceptions -fno-strict-aliasing -Wno-deprecated -g -arch i386 -arch x86_64 -mmacosx-version-min=10.5.4 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0 -I/opt/gtest-1.6.0/include CrazyTest.ccg++ -o cmtest.o -c -Wall -Werror=non-virtual-dtor -pipe -std=c++98 -fno-rtti -fno-exceptions -fno-strict-aliasing -Wno-deprecated -g -arch i386 -arch x86_64 -mmacosx-version-min=10.5.4 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_HAS_RTTI=0 -I/opt/gtest-1.6.0/include cmtest.ccg

  • dmonopoly
    c++ googletest
    I’ve been trying to get used to c++ with cmake and gtest (google test).I’m trying to understand why this setup yields the error Undefined symbols for architecture x86_64: “Project1::foo(int&)”, referenced from:Project1Test_MethodBarDoesAbc_Test::TestBody() in test_project1.cpp.old: symbol(s) not found for architecture x86_64when I run “make”. When I implement methods in the .h file, things work fine; but when I only declare methods in the .h file and then implement it in the associated .cpp file, this error occurs.My test file: test_project1.cpp#include #include “gtest/gtest.h”#include “project1.h”// tests outside of the class TEST(IndependentMethod, ResetsToZero2) {int i = 0;independentMethod(i);EXPECT_EQ(0, i); } //…// The fixture for testing the class class Project1Test : public ::testing::Test { protected

  • Anton
    windows qt mingw googletest
    I have a Qt project and i wanted to use google tests framework GoogleTestFramework in order to do google test. The framework compiled fine on Linux.I have managed to compile the libraries on windows, using tips provided in the following link: Installing Gtest without pthreadsThe following advice do not let me compile the libraries, because of errors due to pthreads: Sackoverflow compiling with MSYSI

  • Baz
    c++ googletest
    Why does a test fixture have a SetUp method in Google Test? Isn’t the Cons

  • Dave Mateer
    qt googletest
    I have a simple test file, TestMe.cpp:#include TEST(MyTest, SomeTest) {EXPECT_EQ(1, 1); }int main(int argc, char **argv) {::testing::InitGoogleTest(&argc, argv);return RUN_ALL_TESTS(); }I have Google Test built as a static library. (I can provide the makefile if it’s relevant.)I can compile TestMe.cpp from a command-line with no problem:g++ TestMe.cpp -IC:\gtest-1.5.0\gtest-1.5.0\include -L../gtest/staticlib -lgte

  • Shafik Yaghmour
    linux gcc googletest
    When I compile gtest samples on Redhat OS(gcc version is 3.2.2),it throw the error as below,howere it compile on Ubuntu it’s OK.Pleae help me. Error or Warning:../include/gtest/internal/gtest-internal.h: In instantiation of `testing::internal::ImplicitlyConvertiblemT,mT);message_data->rUID[0] = ‘\0’;mes

  • BЈовић
    linker-error googletest
    I was trying to set up GTest environment on my Ubuntu machine. but while making the GTest to get the library, i get the following error…som@som-VPCEH25EN:~/Workspace/CPP/gtest-1.6.0/make$ make g++ -I../include -g -Wall -Wextra -lpthread sample1.o sample1_unittest.o gtest_main.a -o sample1_unittest gtest_main.a(gtest-all.o): In function `~ThreadLocal’: /home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1336: undefined reference to `pthread_getspecific’ /home/som/Workspace/CPP/gtest-1.6.0/make/../include/gtest/internal/gtest-port.h:1340: undefined reference

  • Antonio Banderas

  • xtofl
    c++ exception-handling googletest
    Starting to use the googletest ASSERT_THROW clause, it seems that ‘sometimes’ the base type of the thrown exception is handled. I reduced the relevant code section to this:// myexception.h struct myexception : public std::logic_error {myexception(const char* what):std::l

  • prosseek
    stl clang googletest clang++
    I downloaded the gtest 1.6, and compiled it with clang++. export CC=/usr/bin/clang export CXX=/usr/bin/clang++ configure makeI got the libgtest.a, and I copied it into /usr/local/lib/libgtest_clang.a. When I tested with simple C++ code, everything works OK, however, when I tried to use vector in test code, I got these error messages in the build process. Compilation works fine. Undefined symbols for architecture x86_64:”std::basic_string

Originally posted 2013-11-09 21:38:43.