solve the version conflict of google test on ubuntu

本文介绍如何在Ubuntu系统中卸载默认的gtest库并安装所需的版本,通过一个具体的CMakeLists.txt文件示例展示了如何配置和运行gtest单元测试。测试包括了两个测试案例:FactorialTest和IsPrimeTest,每个案例包含三个测试用例。
  1. uninstall the default one on ubuntu
    sudo apt-get remove libgtest-dev
  2. cmakelist.txt
cmake_minimum_required(VERSION 2.8)

project(testGTest)

file(GLOB srcs *.cpp *.hpp *.cc *.h)
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} ${srcs})
target_link_libraries(${PROJECT_NAME} gtest pthread) 
[==========] Running 6 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from FactorialTest
[ RUN      ] FactorialTest.Negative
[       OK ] FactorialTest.Negative (0 ms)
[ RUN      ] FactorialTest.Zero
[       OK ] FactorialTest.Zero (0 ms)
[ RUN      ] FactorialTest.Positive
[       OK ] FactorialTest.Positive (0 ms)
[----------] 3 tests from FactorialTest (0 ms total)

[----------] 3 tests from IsPrimeTest
[ RUN      ] IsPrimeTest.Negative
[       OK ] IsPrimeTest.Negative (0 ms)
[ RUN      ] IsPrimeTest.Trivial
[       OK ] IsPrimeTest.Trivial (0 ms)
[ RUN      ] IsPrimeTest.Positive
[       OK ] IsPrimeTest.Positive (0 ms)
[----------] 3 tests from IsPrimeTest (0 ms total)

[----------] Global test environment tear-down
[==========] 6 tests from 2 test cases ran. (0 ms total)
[  PASSED  ] 6 tests.
[root@node01 ~]# conda install mysqlclient Channels: - defaults Platform: linux-64 Collecting package metadata (repodata.json): done Solving environment: failed LibMambaUnsatisfiableError: Encountered problems while solving: - package mysqlclient-1.3.12-py27h14c3975_0 requires python >=2.7,<2.8.0a0, but none of the providers can be installed Could not solve for environment specs The following packages are incompatible ├─ mysqlclient =* * is installable with the potential options │ ├─ mysqlclient [1.3.12|1.3.13|1.3.14|1.4.4|1.4.6] would require │ │ └─ python >=2.7,<2.8.0a0 *, which can be installed; │ ├─ mysqlclient [1.3.12|1.3.13] would require │ │ └─ python >=3.5,<3.6.0a0 *, which can be installed; │ ├─ mysqlclient [1.3.12|1.3.13|...|2.0.3] would require │ │ └─ python >=3.6,<3.7.0a0 *, which can be installed; │ ├─ mysqlclient [1.3.13|1.3.14|...|2.0.3] would require │ │ └─ python >=3.7,<3.8.0a0 *, which can be installed; │ ├─ mysqlclient [1.4.4|1.4.6|2.0.1|2.0.2|2.0.3] would require │ │ └─ python >=3.8,<3.9.0a0 *, which can be installed; │ ├─ mysqlclient [2.0.2|2.0.3] would require │ │ └─ python >=3.9,<3.10.0a0 *, which can be installed; │ ├─ mysqlclient 2.0.3 would require │ │ └─ python >=3.10,<3.11.0a0 *, which can be installed; │ └─ mysqlclient 2.0.3 would require │ └─ python >=3.11,<3.12.0a0 *, which can be installed; └─ pin on python 3.13.* =* * is not installable because it requires └─ python =3.13 *, which conflicts with any installable versions previously reported. Pins seem to be involved in the conflict. Currently pinned specs: - python=3.13
最新发布
06-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值