小编Hel*_*lam的帖子

已在lib中定义的标准库,导致链接器错误

不知道我在这里做错了什么,但是说我有:

foo.h中

class foo
{
public:
int Get10(std::wstring);
};
Run Code Online (Sandbox Code Playgroud)

Foo.cpp中

int foo::Get10(std::wstring dir)
{
   return 10;
};
Run Code Online (Sandbox Code Playgroud)

我将它编译为lib,如果我将lib包含在另一个项目中以及相关的头文件(foo.h)并尝试调用foo的实例:

foo f;
f.Get10(L"ABC");
Run Code Online (Sandbox Code Playgroud)

我收到链接器错误说:

错误1错误LNK2005:"public:__thiscall std :: _ Container_base12 ::〜_Container_base12(void)"(?? 1_Container_base12 @std @@ QAE @ XZ)已在foo.lib中定义(foo.obj)C:\ foo\msvcprtd .lib(MSVCP100D.dll)footest

任何想法为什么会这样?

c++ linker lnk2005

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

linker ×1

lnk2005 ×1