59

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?

3

3 Answers 3

72

Is it a bug?

No, it's deliberate:

gtest (1.6.0-1ubuntu2) precise; urgency=low

  * Stop distributing static library (although still build it, to ensure gtest
    works).  Upstream recommends against shipping the libary at all, just the
    source. (See: http://code.google.com/p/googletest/wiki/FAQ)
    The Debian maintainer plans to do this also (see BTS: 639795); do it in
    Ubuntu now to fulfil MIR requirements.

To build static libraries

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
10
  • 1
    Thanks! I've built the libraries in this way. Just thought that it might not be an official approach for a .deb package.
    – eddyxu
    Jun 3, 2012 at 14:20
  • 2
    The Google works in mysterious ways! :) Glad it helped.
    – ish
    Jun 3, 2012 at 14:23
  • 2
    Copy-paste version: cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libg* /usr/lib/ && cd -
    – exic
    Jan 16, 2013 at 16:05
  • 3
    Actually reason described here can be applied to any library. For example if boost is linked with libstdc++ and you want to use libc++ you need to recompile boost from sources. So it's strange, IMHO
    – ruslo
    Oct 23, 2013 at 7:51
  • 11
    This is freaking asinine. Why the hell wouldn't they ship the library for the source? Or at least have the package install build it automatically.
    – Fake Name
    Nov 26, 2015 at 3:48
23

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/
1

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)
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .