gcc test.o a.o -o test /usr/local/lib/libgtest_main.a
/usr/local/bin/ld: test.o: warning: relocation against `_ZSt4cerr' in read-only section `.text._ZN7testing8internal8GTestLog9GetStreamEv[_ZN7testing8internal8GTestLog9GetStreamEv]'
/usr/local/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `main':
/nobackup/srcs/googletest-release-1.11.0/build/../googletest/src/gtest_main.cc:51: undefined reference to `testing::InitGoogleTest(int*, char**)'
/usr/local/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `RUN_ALL_TESTS()':
/nobackup/srcs/googletest-release-1.11.0/build/../googletest/include/gtest/gtest.h:2490: undefined reference to `testing::UnitTest::GetInstance()'
/usr/local/bin/ld: /nobackup/srcs/googletest-release-1.11.0/build/../googletest/include/gtest/gtest.h:2490: undefined reference to `testing::UnitTest::Run()'
/usr/local/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `_GLOBAL__sub_I_main':
/usr/include/c++/7/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/local/bin/ld: /usr/include/c++/7/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
any idea?g++
to linkg++ -Wall -Wextra -g -c test.cpp -o test.o
gcc -Wall -Wextra -g -c a.c -o a.o
g++ test.o a.o -o test /usr/local/lib/libgtest_main.a
/usr/local/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `main':
/nobackup/srcs/googletest-release-1.11.0/build/../googletest/src/gtest_main.cc:51: undefined reference to `testing::InitGoogleTest(int*, char**)'
/usr/local/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `RUN_ALL_TESTS()':
/nobackup/srcs/googletest-release-1.11.0/build/../googletest/include/gtest/gtest.h:2490: undefined reference to `testing::UnitTest::GetInstance()'
/usr/local/bin/ld: /nobackup/srcs/googletest-release-1.11.0/build/../googletest/include/gtest/gtest.h:2490: undefined reference to `testing::UnitTest::Run()'
/usr/local/bin/ld: test.o: in function `first_test_Test::TestBody()':
/home/ve257822/work/ater/px222/2022-2023/scratch/test.cpp:7: undefined reference to `testing::Message::Message()'
g++ test.o a.o -o test /usr/local/lib/libgtest_main.a /usr/local/lib/libgtest.a -lrt -ldl -pthread
libgtest_main.a
library if you don't provide a main function yourselflibgtest_main.a
library if you don't provide a main function yourself