0

I am attempting to use google test to validate some testing of a red-black-tree implementation in C++. I am following the top rated answer from this post. I've made sure to account for the fact the newest distro of Google Test is version 1.10.0, not 1.8.0. The steps I take to attempt to install and link the libraries are as follows:

First, I get the latest Google Test framework like so:

wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz

and this successfully installs. Next, I'm able to unpack and and build the shared libraries of google test in the new googletest-release-1.10.0 folder. Calling make after calling:

cmake -DBUILD_SHARED_LIBS=ON .

Leads to this message:

[ 25%] Built target gtest
[ 50%] Built target gmock
[ 75%] Built target gmock_main
[100%] Built target gtest_main

The issue seems to occur in the step where I copy the headers in the libraries in the correct directory. I can do this

 sudo cp -a googletest/include/gtest /usr/include

But my system is unable to find the files in googlemock/gtest: Attempting to copy these files:

sudo cp -a googlemock/gtest/libgtest_main.so googlemock/gtest/libgtest.so /usr/lib/

Gives me the error no such files exist:

cp: cannot stat 'googlemock/gtest/libgtest_main.so': No such file or directory
cp: cannot stat 'googlemock/gtest/libgtest.so': No such file or directory

2 Answers2

0

when you build the package, you will get a directory like this:

├── appveyor.yml
├── bin
├── BUILD.bazel
├── ci
├── CMakeCache.txt
├── CMakeFiles
├── cmake_install.cmake
├── CMakeLists.txt
├── CONTRIBUTING.md
├── CTestTestfile.cmake
├── googlemock
├── googletest
├── lib
├── library.json
├── LICENSE
├── Makefile
├── platformio.ini
├── README.md
└── WORKSPACE

The files you are unable to find are in the lib folder.

lib
├── libgmock_main.so
├── libgmock.so
├── libgtest_main.so
└── libgtest.so
0

I don't think you should use cp -a. Since the copied .so file in /usr/lib seems have unavaliable autorities for compile.

My CMakeList.txt is like this:

add_executable(Test test.cc)
target_link_libraries(Test /usr/lib/libgtest.so /usr/lib/libgtest_main.so -pthread)

If you use cp -a, during make process there will be an error like:

make[2]: *** No rule to make target '/usr/lib/libgtest.so', needed by 'Test'.  Stop.

So I only use cp, and there is nothing wrong.