Google在Windows上用Eclipse进行测试

Google test with Eclipse on Windows

本文关键字:测试 Eclipse 上用 Windows Google      更新时间:2023-10-16

我正在尝试使用Eclipse设置google测试。以下是我目前所做的:

初始设置:

    在Eclipse Helios上安装CDT。
  1. 已下载并安装Cygwin。
  2. 下载并解压gtest.
  3. 使用cygwin构建gtest,使用默认的makefile。
在eclipse中

:

  1. 在工具链中用Cygwin创建了一个空的可执行c++项目。
  2. 在c++ Build/Settings/Cygwin c++ Compiler
  3. 中添加了"[gtest_dir]include"
  4. 添加库路径为"[gtest_dir]make"在c++ Build/Settings/Cygwin c++ link
  5. Builder已经是GNU Make Builder
  6. 编写了一些c++代码示例并构建了项目。

当我构建项目时,我面临以下错误:

构建目标:SampleCpp.exe调用:Cygwin c++链接器g++ -L/cygdrive/d/gtest-1.7.0/make -o"SampleCpp.exe" ./src/Counter. exeo。/src/Counter_tests。o -lgtest/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: cannot find -lgtest makefile:45:目标'SampleCpp.exe'的配方失败

我错过了什么?

EDIT 1: [gtest_dir]make包含两个.a文件- gt。agtest_main.a

我也使用Eclipse Helios

EDIT 2:

它工作后,我重命名gtest。gtest.lib。这是Windows上库的预期命名格式吗?

在C/c++ Build> Settings> Tool Settings> Cygwin c++ Linker> Miscellaneous> Other Objects下,添加$GTEST_DIR/make/gtest_main.a。

这会使链接器看到gtest_main。A作为目标文件的存档,而不是库。