【发布时间】:2019-05-28 09:36:19
【问题描述】:
我在 Eclipse 中使用 google test(gtest),这是我的代码
测试.h
#ifndef TEST_H_
#define TEST_H_
int Foo(int a, int b);
#endif
test.cpp
#include<iostream>
#include "test.h"
int Foo(int a, int b) {
return a + b;}
main.cpp
#include "test.h"
#include "gtest/gtest.h"
TEST(FooTest, HandleNoneZeroInput)
{
EXPECT_EQ(2, Foo(4, 10));
EXPECT_EQ(6, Foo(30, 18));
}
int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
这是我的 Eclipse 配置:
Library Paths F:\GTEST\googletest\googletest\mybuild\lib
Libraries libgtest
Includes F:\GTEST\googletest\googletest\include
我的文件夹F:\GTEST\googletest\googletest\mybuild\lib 中有两个文件,分别名为libgtest.a 和libgtest_main.a
我构建了我的项目,eclipse 产生了一个错误:
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -llibgtest
注意:
我的工作环境是windows7_64, mingw32, gcc 6.3.0, eclipse
谢谢你,我希望你的解决方案。
【问题讨论】:
-
我解决了这个问题,但我遇到了另一个问题
-
这些错误很多,例如“未定义对 `testing::Message::Message()' 的引用”
标签: c++ eclipse gcc mingw googletest