gtest in eclipse error:ld.exe can not find -llibgtest
gtest in eclipse error:ld.exe can not find -llibgtest
我在 eclipse 中使用 google test(gtest),这是我的代码
test.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();
}
这是我的日食配置:
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
谢谢你,我希望你的解决方案。
解决方法很简单。当库列在 Eclipse 配置的库部分时,应省略 "lib" 前缀:
Libraries gtest gtest_main
我在 eclipse 中使用 google test(gtest),这是我的代码
test.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();
}
这是我的日食配置:
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
谢谢你,我希望你的解决方案。
解决方法很简单。当库列在 Eclipse 配置的库部分时,应省略 "lib" 前缀:
Libraries gtest gtest_main