2009-05-24 62 views
0

我试图从nVidia的9.5 SDK构建的代码,但我得到以下链接错误:链接错误LNK2019 - 不知道为什么

>1>NV_D3DCommonDX9U.lib(NV_StringFuncs.obj) : error LNK2005: "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl std::getline<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_istream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) already defined in msvcprtd.lib(MSVCP90D.dll) 
1>FogTombScene.obj : error LNK2019: unresolved external symbol "public: struct IDirect3DTexture9 * * __thiscall TextureFactory::CreateTextureFromFile(struct IDirect3DDevice9 *,wchar_t const *,bool)" ([email protected]@@[email protected]@[email protected]@[email protected]) referenced in function "public: virtual long __thiscall FogTombScene::RestoreDeviceObjects(void)" ([email protected]@@UAEJXZ) 
1>FogTombScene.obj : error LNK2019: unresolved external symbol "public: long __thiscall LoadXFile::LoadFile(wchar_t const *,bool)" ([email protected]@@[email protected]) referenced in function "public: virtual long __thiscall FogTombScene::RestoreDeviceObjects(void)" ([email protected]@@UAEJXZ) 
1>FogTombScene.obj : error LNK2019: unresolved external symbol "public: long __thiscall LoadXFile::Initialize(struct IDirect3DDevice9 *,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > (__cdecl*)(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,bool),class TextureFactory * *)" ([email protected]@@[email protected]@[email protected][email protected][email protected]@@[email protected][email protected]@@[email protected]@[email protected][email protected]@@@Z) referenced in function "public: virtual long __thiscall FogTombScene::RestoreDeviceObjects(void)" ([email protected]@@UAEJXZ) 
1>NV_D3DCommonDX9U.lib(NV_StringFuncs.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::locale::facet::_Register(void)" ([email protected]@[email protected]@@QAEXXZ) referenced in function "class std::ctype<char> const & __cdecl std::use_facet<class std::ctype<char> >(class std::locale const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>NV_D3DCommonDX9U.lib(NV_StringFuncs.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::ctype<char>::_Getcat(class std::locale::facet const * *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "class std::ctype<char> const & __cdecl std::use_facet<class std::ctype<char> >(class std::locale const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z) 
1>NV_D3DCommonDX9U.lib(NV_StringFuncs.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static unsigned int __cdecl std::ctype<unsigned short>::_Getcat(class std::locale::facet const * *)" ([email protected][email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "class std::ctype<unsigned short> const & __cdecl std::use_facet<class std::ctype<unsigned short> >(class std::locale const &)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected]@Z) 

我不知道为什么我gettin gthese的恐惧,因为我99%确定我已经正确设置了我的目录。

例如,它找不到的函数之一是TextureFactory :: CreateTextureFromFile,但我有一个目录,该函数声明和定义已添加到Visual C++设置中的include/source目录中。

顶部的文件看起来是这样的:

#include "nvafx.h" 
//#include "NV_D3DCommon\NV_D3DCommonDX9.h" // include library sub-headers 
              // and add .lib to linker inputs 
//#include "NV_D3DMesh\NV_D3DMesh.h" 

//#include "shared\NV_Common.h" 
//#include "shared\NV_Error.h" 

#include "FogTombScene.h" 
#include "ThicknessRenderProperties.h" 
#include "ThicknessRenderProperties8BPC.h" 
#include "../camera.h" 


// When the following two lines are added I get more LNK2005 (understandable) 
// but I also still get the same LNK2019 errors as above 
#include "texturefactory.h" 
#include "texturefactory.cpp" 

更重要的一点,如果我说的#include“TextureFactory.h”和#包括“texturefactory.cpp”在文件的顶部,我如果出现这些错误,那么就不存在模糊不清的空间,函数会被定义并基本上被复制粘贴到生成链接器错误的同一个源文件中,但我仍然会收到链接器错误。

我可以俯视吗?

+0

请显示源文件的顶部,以显示包含头文件(包括texturefactory.cpp)的顺序。 – ChrisW 2009-05-24 19:04:30

回答

2

这happend因为:

1的.lib的源缺少像说tomzx或丹尼尔, 或 二是在Visual C 尝试另一个版本编译的的.lib创建文件像.c(不是一个.cpp)在记事本中,然后你添加到你的项目文件.c(项目...添加到项目...文件)

对不起,我是墨西哥人,我不会说英语。 Saludos。

2

您已将文件添加到include/source文件夹中,但是库怎么办?看起来更像是一个图书馆问题(缺少.lib)。

也许你还需要在链接器 - 输入中列出你的依赖关系。

LNK2005通常意味着额外的库没有正确链接。

2

您可能忘记了链接到其中一个SDK的lib文件。您可以在链接器 - >输入 - >附加依赖关系下的项目属性中设置此项,或使用#pragma comment