Install Google Test Framework Google Test on Ubuntu 20.04
Recently I’ve updated Ubuntu to version 20.04. After that I’d noticed there was an issue when installing Google Test framework gtest. I’ve found the top BING/GOOGLE search result about this subject was pointing to this blog: https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
However, we need to do a little change in the last step. Here’s the step by step installing Google Test Framework:
step 1:
sudo apt-get install libgtest-dev
Step 2:
sudo apt-get install cmake
Step 3:
cd /usr/src/gtest
sudo cmake CMakeLists.txt
Step 4:
sudo make
Step 5:
If you followed Erik’s link, you would get error here:
To solve this error, first let’s find out the location of the *.a files. There are two .a files we need to copy
find . -name “libgtest*.a”
As we can see these two files were under ./lib sub folder.
So the correct command should be:
sudo cp ./lib/libgtest*.a /usr/lib
Please be noted I’ve copied the two files to /usr/local/lib instead of /usr/lib. It’s up to you but prefer to copying them to local lib folder.
I will create another blog about using Google gtest.
Cheers!