gtest in eclipse error:ld.exe can not find -llibgtest
gtest in eclipse error:ld.exe can not find -llibgtest
我在 eclipse 中使用 google test(gtest),这是我的代码
测试.h
#ifndef TEST_H_
#define TEST_H_
int Foo(int a, int b);
#endif
测试.cpp
#include<iostream>
#include "test.h"
int Foo(int a, int b) {
return a + b;}
主.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:GTESTgoogletestgoogletestmybuildlib
Libraries libgtest
Includes F:GTESTgoogletestgoogletestinclude
我的文件夹中有两个文件F:GTESTgoogletestgoogletestmybuildlib
分别名为libgtest.a
和libgtest_main.a
我构建了我的项目,日食产生了一个错误:
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
相关文章:
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 使用JsonCpp将数据返回到带有pybind11的python会在python调用中产生Symbol not foun
- OpenCV Android C++ imwrite not found
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 使用单词"not"作为C ++类的名称会导致VS2019错误
- 错误"Could not find Boost"(缺少:上下文标头)
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- Is !NaN not a NaN?
- _BitScanForward64 can not be found
- 解决方法:'can not be used when making a shared object; recompile with -fPIC'使用Cmake。使用普通的 g++ 工作
- gtest in eclipse error:ld.exe can not find -llibgtest
- " 'yc' can not be used as a function"错误C++
- 函数中的C ++-"a reference .. can not be initialized with a value"的错误
- Boost can not find lib
- 构建 Pixman 库时,提示总是说 "can not find xxx.h(the std header" ?
- 取消引用迭代器会导致'can not convert'错误,而它似乎不应该
- 我在Visual Studio中运行了一个Qt C++项目,但缺少"the program can not start because QtCored4.dll"
- 链接错误:"relocation R_X86_64_32 ... can not be used when making a shared object; recompile with -fPIC"
- 协同创建实例失败,并显示错误"System can not find the file specified"