google / googletest

GoogleTest - Google Testing and Mocking Framework

Home Page:https://google.github.io/googletest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

apple M1 chip Mac build failed because of */libgtest.a does not contain the arm64 architecture.

WalleLoveEva opened this issue · comments

Describe the bug

Include a clear and concise description of what the problem is, including what
you expected to happen, and what actually happened.

Showing All Issues
Ignoring file /Users/walle.fu/.conan/data/googletest/1.8.1/mthor/stable/package/105876dec92f9a83153bf5fcecc0fc2571d7ba2f/lib/libgtest.a, file is universal (x86_64) but does not contain the arm64 architecture: /Users/walle.fu/.conan/data/googletest/1.8.1/mthor/stable/package/105876dec92f9a83153bf5fcecc0fc2571d7ba2f/lib/libgtest.a

Undefined symbol: testing::InitGoogleTest(int*, char**)

Undefined symbol: testing::AssertionResult::AssertionResult(testing::AssertionResult const&)

Undefined symbol: testing::AssertionFailure()

Undefined symbol: testing::AssertionSuccess()

Undefined symbol: testing::Test::Test()

Undefined symbol: testing::Test::~Test()

Undefined symbol: testing::Message::Message()

Undefined symbol: testing::UnitTest::GetInstance()

Undefined symbol: testing::UnitTest::AddEnvironment(testing::Environment*)

Undefined symbol: testing::UnitTest::Run()

Undefined symbol: testing::internal::CmpHelperEQ(char const*, char const*, long long, long long)

Undefined symbol: testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)

Undefined symbol: testing::internal::AssertHelper::~AssertHelper()

Undefined symbol: testing::internal::PrintStringTo(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_ostream<char, std::__1::char_traits >*)

Undefined symbol: testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void ()(), void ()(), testing::internal::TestFactoryBase*)

Undefined symbol: testing::internal::GetBoolAssertionFailureMessage(testing::AssertionResult const&, char const*, char const*, char const*)

Undefined symbol: testing::internal::IsTrue(bool)

Undefined symbol: testing::internal::EqFailure(char const*, char const*, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, bool)

Undefined symbol: testing::internal2::PrintBytesInObjectTo(unsigned char const*, unsigned long, std::__1::basic_ostream<char, std::__1::char_traits >*)

Undefined symbol: testing::Message::GetString() const

Undefined symbol: testing::internal::AssertHelper::operator=(testing::Message const&) const

Undefined symbol: typeinfo for testing::Test

Steps to reproduce the bug

It's important that we are able to reproduce the problem that you are
experiencing. Please provide all code and relevant steps to reproduce the
problem, including your BUILD/CMakeLists.txt file and build commands. Links
to a GitHub branch or godbolt.org that demonstrate the
problem are also helpful.

Does the bug persist in the most recent commit?

We recommend using the latest commit in the master branch in your projects.

What operating system and version are you using?
MAC pro 2021

If you are using a Linux distribution please include the name and version of the
distribution as well.

What compiler and version are you using?
Clang 13
Xcode 13.3.1

Please include the output of gcc -v or clang -v, or the equivalent for your
compiler.

What build system are you using?
Mac OS 12.3.1

Please include the output of bazel --version or cmake --version, or the
equivalent for your build system.

Additional context

Add any other context about the problem here.

Hello. The steps to reproduce the bug are missing. Please provide a sample program and all compile commands.

commented

@derekmauro

Test code:

example.test.cpp

#include <gtest/gtest.h>

TEST(YetAnotherSimpleGTest, ExpectGQ) {
    int actual = 1;
    EXPECT_GT(actual, 0);
    EXPECT_EQ(1, actual) << "Should be equal to one";
}

int main(int argc, char **argv) {
    testing::InitGoogleTest(&argc, argv);

    RUN_ALL_TESTS(); 
}

gtest version: 1.12.1

Command used to build tests: cmake -DCMAKE_CXX_FLAGS=-std=c++14 ..

Computer model: MacBook Pro M1 2021

Operative system version: Ventura 13.0

Xcode version: Xcode 14.0
Clang version: 14

Command used to run tests:

clang++ -Wall -std=c++14 example.test.cpp -o test && ./test

Error:

ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Full stack trace

Undefined symbols for architecture arm64:
  "testing::InitGoogleTest(int*, char**)", referenced from:
      _main in fibonacci-fce83f.o
  "testing::AssertionResult::AssertionResult(testing::AssertionResult const&)", referenced from:
      testing::AssertionResult testing::internal::CmpHelperOpFailure<int, int>(char const*, char const*, int const&, int const&, char const*) in fibonacci-fce83f.o
  "testing::AssertionFailure()", referenced from:
      testing::AssertionResult testing::internal::CmpHelperOpFailure<int, int>(char const*, char const*, int const&, int const&, char const*) in fibonacci-fce83f.o
  "testing::AssertionSuccess()", referenced from:
      testing::AssertionResult testing::internal::CmpHelperGT<int, int>(char const*, char const*, int const&, int const&) in fibonacci-fce83f.o
      testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&) in fibonacci-fce83f.o
  "testing::Test::SetUp()", referenced from:
      vtable for YetAnotherBrokenKeyboard_RecursiveFib_Test in fibonacci-fce83f.o
  "testing::Test::TearDown()", referenced from:
      vtable for YetAnotherBrokenKeyboard_RecursiveFib_Test in fibonacci-fce83f.o
  "testing::Test::Test()", referenced from:
      YetAnotherBrokenKeyboard_RecursiveFib_Test::YetAnotherBrokenKeyboard_RecursiveFib_Test() in fibonacci-fce83f.o
  "testing::Test::~Test()", referenced from:
      YetAnotherBrokenKeyboard_RecursiveFib_Test::~YetAnotherBrokenKeyboard_RecursiveFib_Test() in fibonacci-fce83f.o
  "testing::Message::Message()", referenced from:
      YetAnotherBrokenKeyboard_RecursiveFib_Test::TestBody() in fibonacci-fce83f.o
      testing::AssertionResult& testing::AssertionResult::operator<<<char [12]>(char const (&) [12]) in fibonacci-fce83f.o
      testing::AssertionResult& testing::AssertionResult::operator<<<char const*>(char const* const&) in fibonacci-fce83f.o
      testing::AssertionResult& testing::AssertionResult::operator<<<char [3]>(char const (&) [3]) in fibonacci-fce83f.o
      testing::AssertionResult& testing::AssertionResult::operator<<<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 fibonacci-fce83f.o
      testing::AssertionResult& testing::AssertionResult::operator<<<char [5]>(char const (&) [5]) in fibonacci-fce83f.o
  "testing::UnitTest::GetInstance()", referenced from:
      RUN_ALL_TESTS() in fibonacci-fce83f.o
  "testing::UnitTest::Run()", referenced from:
      RUN_ALL_TESTS() in fibonacci-fce83f.o
  "testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)", referenced from:
      YetAnotherBrokenKeyboard_RecursiveFib_Test::TestBody() in fibonacci-fce83f.o
  "testing::internal::AssertHelper::~AssertHelper()", referenced from:
      YetAnotherBrokenKeyboard_RecursiveFib_Test::TestBody() in fibonacci-fce83f.o
  "testing::internal::GetTestTypeId()", referenced from:
      ___cxx_global_var_init in fibonacci-fce83f.o
  "testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)", referenced from:
      ___cxx_global_var_init in fibonacci-fce83f.o
  "testing::internal::IsTrue(bool)", referenced from:
      testing::internal::SuiteApiResolver<testing::Test>::GetSetUpCaseOrSuite(char const*, int) in fibonacci-fce83f.o
      testing::internal::SuiteApiResolver<testing::Test>::GetTearDownCaseOrSuite(char const*, int) in fibonacci-fce83f.o
  "testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)", referenced from:
      testing::internal::SuiteApiResolver<testing::Test>::GetSetUpCaseOrSuite(char const*, int) in fibonacci-fce83f.o
      testing::internal::SuiteApiResolver<testing::Test>::GetTearDownCaseOrSuite(char const*, int) in fibonacci-fce83f.o
  "testing::internal::GTestLog::~GTestLog()", referenced from:
      testing::internal::SuiteApiResolver<testing::Test>::GetSetUpCaseOrSuite(char const*, int) in fibonacci-fce83f.o
      testing::internal::SuiteApiResolver<testing::Test>::GetTearDownCaseOrSuite(char const*, int) in fibonacci-fce83f.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::CmpHelperEQFailure<int, int>(char const*, char const*, int const&, int const&) in fibonacci-fce83f.o
      ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Hi I have encountered the same issue.