google test安装

#复制代码到本地
git clone [email protected]:google/googletest.git


cd googletest/googletest/

#在CMakeList.txt中作如下修改
#添加一行
SET( CMAKE_CXX_FLAGS "-std=c++11 -O3")
#将下面一行的OFF改成ON
  # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
  # make it prominent in the GUI.
  option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)

  option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." ON)

cmake CMakeLists.txt 
make
sudo cp lib/libgtest*.so /usr/lib
sudo cp -a include/gtest/ /usr/include/
sudo ldconfig

#使用时将库链接进工程即可
#target_link_libraries(${CMAKE_PROJECT_NAME}
#       gtest
#       )
#
#
#

 

你可能感兴趣的:(C++,linux)