The libgtest-dev package seems only install header files to the system, but not the static and dynamic libraries which should be installed under /usr/lib.
Is it a bug?
The libgtest-dev package seems only install header files to the system, but not the static and dynamic libraries which should be installed under /usr/lib.
Is it a bug?
Is it a bug?
No, it's deliberate:
gtest (1.6.0-1ubuntu2) precise; urgency=low
cd /usr/src/gtest sudo cmake . sudo make sudo mv libg* /usr/lib/
Edit:
The names have changed slightly over the years, though the process remains the same. In Ubuntu 17.04:
sudo apt-get install libgtest-dev
cd /usr/src/googletest/googletest
sudo mkdir build
cd build
sudo cmake ..
sudo make
sudo cp libgtest* /usr/lib/
cd ..
sudo rm -rf build
/usr/src/ with binaries.
– Marco Leogrande
Oct 16 '12 at 22:39
cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libg* /usr/lib/ && cd -
– exic
Jan 16 '13 at 16:05
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
– Paresh471
Jul 18 '18 at 14:47
Improving on izx's answer I would have used cmake this way:
sudo cmake -DCMAKE_BUILD_TYPE=RELEASE .
and I would attempt an out-of-source build:
cd /tmp
mkdir .build
cd .build
cmake -DCMAKE_BUILD_TYPE=RELEASE /usr/src/gtest/
make
sudo mv libg* /usr/lib/
Note that the recommended way by google is to have your existing project pull the gtest source code in.
Alternatively, when using with CMake, you can use add_subdirectory to add the gtest source that came with libgtest-dev since it by default goes into /usr/src/googletest.
The following will work
add_subdirectory(/usr/src/googletest gtest)
target_link_libraries(your_executable gtest)