Installing googletest and googlemock v1.8.0 as shared libraries

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
User avatar
DaveC49
Level 1
Level 1
Posts: 46
Joined: Thu Oct 02, 2014 7:41 pm

Installing googletest and googlemock v1.8.0 as shared libraries

Post by DaveC49 » Tue Apr 10, 2018 2:44 am

I had some difficulty working out how to get googletest and googlemock installed properly as shared libraries on Linux Mint. Looking at a number of Ubuntu and forum posts, quite a few others have had some difficulty as well. Hope this helps someonelse out.

The following procedure using Cmake worked although it may not be minimal. The -DBUILD_GTEST and -DBUILD_GMOCK flags are possibly not necessary as these appear to be the defaults. It would appear that -DINSTALL_GTEST and -DINSTALL_GMOCK are also the default options, but I was making sure.

# Build instructions for googletest (gtest) and googlemock (gmock) v 1.8.0
# with googlemock incorporated within Googletest on Linux Mint 18.3
#
# download googletest-master.zip from https://github.com/google/googletest
# and extract into a suitable folder under your home directory
# and then change into the "googletest-master" folder.
#
# or
#
# checkout with git
#
$git clone https://github.com/google/googletest.git
#
# and cd into the "googletest" folder
$cd googletest
#
# now create a build directory and cd into it
$mkdir mybuild
$cd mybuild
#
# Build both the googletest and googlemock libraries
# using Cmake. Note ../ will take you back to the CMakeLists.txt
# in either the googletest or the googletest-master directory
#
$cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=ON -DINSTALL_GTEST=ON -DINSTALL_GMOCK=ON ../
# note $cmake -DBUILD_GMOCK=ON -DINSTALL_GMOCK=ON -DINSTALL_GTEST=ON ../
# should work equally as well as BUILD_GMOCK=ON should build GTEST by default
#
# then use make to build the libraries
#
# $make this appears to be redundant
#
# then install the libraries
#
$sudo make install
#which produced the following output:
[ 25%] Built target gtest
[ 50%] Built target gmock
[ 75%] Built target gmock_main
[100%] Built target gtest_main
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libgmock.so
-- Set runtime path of "/usr/local/lib/libgmock.so" to ""
-- Installing: /usr/local/lib/libgmock_main.so
-- Set runtime path of "/usr/local/lib/libgmock_main.so" to ""
-- Up-to-date: /usr/local/include/gmock
-- Installing: /usr/local/include/gmock/gmock-generated-matchers.h.pump
-- Installing: /usr/local/include/gmock/gmock-generated-function-mockers.h.pump
-- Up-to-date: /usr/local/include/gmock/internal
-- Installing: /usr/local/include/gmock/internal/gmock-generated-internal-utils.h.pump
-- Installing: /usr/local/include/gmock/internal/gmock-generated-internal-utils.h
-- Installing: /usr/local/include/gmock/internal/gmock-internal-utils.h
-- Installing: /usr/local/include/gmock/internal/gmock-port.h
-- Up-to-date: /usr/local/include/gmock/internal/custom
-- Installing: /usr/local/include/gmock/internal/custom/gmock-generated-actions.h.pump
-- Installing: /usr/local/include/gmock/internal/custom/gmock-port.h
-- Installing: /usr/local/include/gmock/internal/custom/gmock-generated-actions.h
-- Installing: /usr/local/include/gmock/internal/custom/gmock-matchers.h
-- Installing: /usr/local/include/gmock/gmock-generated-matchers.h
-- Installing: /usr/local/include/gmock/gmock-more-actions.h
-- Installing: /usr/local/include/gmock/gmock-cardinalities.h
-- Installing: /usr/local/include/gmock/gmock-generated-function-mockers.h
-- Installing: /usr/local/include/gmock/gmock-generated-actions.h.pump
-- Installing: /usr/local/include/gmock/gmock-spec-builders.h
-- Installing: /usr/local/include/gmock/gmock.h
-- Installing: /usr/local/include/gmock/gmock-generated-nice-strict.h.pump
-- Installing: /usr/local/include/gmock/gmock-more-matchers.h
-- Installing: /usr/local/include/gmock/gmock-actions.h
-- Installing: /usr/local/include/gmock/gmock-generated-actions.h
-- Installing: /usr/local/include/gmock/gmock-matchers.h
-- Installing: /usr/local/include/gmock/gmock-generated-nice-strict.h
-- Installing: /usr/local/lib/pkgconfig/gmock.pc
-- Installing: /usr/local/lib/pkgconfig/gmock_main.pc
-- Installing: /usr/local/lib/libgtest.so
-- Installing: /usr/local/lib/libgtest_main.so
-- Set runtime path of "/usr/local/lib/libgtest_main.so" to ""
-- Up-to-date: /usr/local/include/gtest
-- Installing: /usr/local/include/gtest/gtest_pred_impl.h
-- Installing: /usr/local/include/gtest/gtest-message.h
-- Up-to-date: /usr/local/include/gtest/internal
-- Installing: /usr/local/include/gtest/internal/gtest-tuple.h.pump
-- Installing: /usr/local/include/gtest/internal/gtest-tuple.h
-- Installing: /usr/local/include/gtest/internal/gtest-port-arch.h
-- Installing: /usr/local/include/gtest/internal/gtest-type-util.h
-- Installing: /usr/local/include/gtest/internal/gtest-linked_ptr.h
-- Installing: /usr/local/include/gtest/internal/gtest-death-test-internal.h
-- Installing: /usr/local/include/gtest/internal/gtest-string.h
-- Installing: /usr/local/include/gtest/internal/gtest-internal.h
-- Installing: /usr/local/include/gtest/internal/gtest-type-util.h.pump
-- Installing: /usr/local/include/gtest/internal/gtest-filepath.h
-- Installing: /usr/local/include/gtest/internal/gtest-param-util-generated.h.pump
-- Installing: /usr/local/include/gtest/internal/gtest-port.h
-- Installing: /usr/local/include/gtest/internal/gtest-param-util.h
-- Up-to-date: /usr/local/include/gtest/internal/custom
-- Installing: /usr/local/include/gtest/internal/custom/gtest.h
-- Installing: /usr/local/include/gtest/internal/custom/gtest-port.h
-- Installing: /usr/local/include/gtest/internal/custom/gtest-printers.h
-- Installing: /usr/local/include/gtest/internal/gtest-param-util-generated.h
-- Installing: /usr/local/include/gtest/gtest.h
-- Installing: /usr/local/include/gtest/gtest_prod.h
-- Installing: /usr/local/include/gtest/gtest-param-test.h.pump
-- Installing: /usr/local/include/gtest/gtest-param-test.h
-- Installing: /usr/local/include/gtest/gtest-death-test.h
-- Installing: /usr/local/include/gtest/gtest-spi.h
-- Installing: /usr/local/include/gtest/gtest-typed-test.h
-- Installing: /usr/local/include/gtest/gtest-test-part.h
-- Installing: /usr/local/include/gtest/gtest-printers.h
-- Installing: /usr/local/lib/pkgconfig/gtest.pc
-- Installing: /usr/local/lib/pkgconfig/gtest_main.pc

User avatar
DaveC49
Level 1
Level 1
Posts: 46
Joined: Thu Oct 02, 2014 7:41 pm

Re: Installing googletest and googlemock v1.8.0 as shared libraries

Post by DaveC49 » Wed Apr 11, 2018 2:22 am

Apologies I missed one flag - add -D BUILD_SHARED_LIBS=ON to the cmake line otherwise it will not build and deploy the libgtest.so, libgtest_main.so, libgmock.so and libgmock_main.so to /usr/local/lib

Post Reply

Return to “Tutorials”