Last active
June 17, 2025 20:27
-
-
Save byates/cbb356377ed4ba4988940595e4e7789c to your computer and use it in GitHub Desktop.
Install GTest library in Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [[ $(id -u $USER) = 0 ]]; then | |
# If we are running as root, then we don't need (and may not have) sudo | |
echo "Userid=$(id -u $USER)" | |
SUDO= | |
else | |
SUDO=sudo | |
fi | |
# https://gist.github.com/Cartexius/4c437c084d6e388288201aadf9c8cdd5 | |
$SUDO apt install -y libgtest-dev lcov | |
cd /usr/src/googletest/googletest/ | |
$SUDO cmake CMakeLists.txt | |
$SUDO make | |
$SUDO cp lib/*.a /usr/lib | |
$SUDO mkdir /usr/local/lib/googletest | |
$SUDO ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a | |
$SUDO ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment