0

I use google test(gtest) in eclipse, here's my code

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();
}

here's my eclipse configuration:

Library Paths    F:\GTEST\googletest\googletest\mybuild\lib


Libraries        libgtest


Includes         F:\GTEST\googletest\googletest\include

there are two files in my folder F:\GTEST\googletest\googletest\mybuild\lib which named libgtest.a and libgtest_main.a

I build my project and eclipse produces an error:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -llibgtest

Note:

My work environment is windows7_64, mingw32, gcc 6.3.0, eclipse

thank you and I wish your solutions.

ShivaGaire
  • 2,283
  • 1
  • 20
  • 31
tianyu
  • 119
  • 1
  • 10

1 Answers1

1

The solution is simple. "lib" prefix should be omitted when libraries are listed in the Libraries section of Eclipse configuration:

Libraries        gtest gtest_main
273K
  • 29,503
  • 10
  • 41
  • 64