views:

1387

answers:

3

I'm trying to build code from the nVidia 9.5 SDK but I get the following linker errors:

>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> > &)" (??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@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)" (?CreateTextureFromFile@TextureFactory@@QAEPAPAUIDirect3DTexture9@@PAUIDirect3DDevice9@@PB_W_N@Z) referenced in function "public: virtual long __thiscall FogTombScene::RestoreDeviceObjects(void)" (?RestoreDeviceObjects@FogTombScene@@UAEJXZ)
1>FogTombScene.obj : error LNK2019: unresolved external symbol "public: long __thiscall LoadXFile::LoadFile(wchar_t const *,bool)" (?LoadFile@LoadXFile@@QAEJPB_W_N@Z) referenced in function "public: virtual long __thiscall FogTombScene::RestoreDeviceObjects(void)" (?RestoreDeviceObjects@FogTombScene@@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 * *)" (?Initialize@LoadXFile@@QAEJPAUIDirect3DDevice9@@P6A?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ABV34@_N@ZPAPAVTextureFactory@@@Z) referenced in function "public: virtual long __thiscall FogTombScene::RestoreDeviceObjects(void)" (?RestoreDeviceObjects@FogTombScene@@UAEJXZ)
1>NV_D3DCommonDX9U.lib(NV_StringFuncs.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::locale::facet::_Register(void)" (__imp_?_Register@facet@locale@std@@QAEXXZ) referenced in function "class std::ctype<char> const & __cdecl std::use_facet<class std::ctype<char> >(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@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 * *)" (__imp_?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z) referenced in function "class std::ctype<char> const & __cdecl std::use_facet<class std::ctype<char> >(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@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 * *)" (__imp_?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z) referenced in function "class std::ctype<unsigned short> const & __cdecl std::use_facet<class std::ctype<unsigned short> >(class std::locale const &)" (??$use_facet@V?$ctype@G@std@@@std@@YAABV?$ctype@G@0@ABVlocale@0@@Z)

I have no idea why I'm gettin gthese terrors because I'm 99% sure I've setup my directories correctly.

For example one of the functions it can't find is TextureFactory::CreateTextureFromFile yet I have the directory in which that function is declared and defined already added to the include/source directory in the Visual C++ settings.

Top of the file looks like this:

#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"

More to the point if I say #include "TextureFactory.h" and #include "texturefactory.cpp" at the top of the file in which I'm getting these errors then there can be no room for ambiguity, the functions are defined and basically copy+pasted into the same source file generating the linker error, yet I still get the linker error.

Am I overlooking something?

+2  A: 

You have added the files in the include/source folder, but what about the libraries? Looks more like a library problem to me (missing .lib).

Maybe you also need to list your dependencies in Linker - Input.

LNK2005 generally means that additionnal libraries aren't correctly linked.

tomzx
+2  A: 

You probably forgot to link to one of the SDKs lib files. You can set this in your project properties under Linker->Input->Additional Dependencies or use a #pragma comment.

Idan K
+1  A: 

That happend because:

1 The source of .lib is missing like said tomzx or Daniel, or 2 The .lib it was compiled in another version of Visual C try to create your file like a .c (NOT a .cpp) in note pad, then you add to your proyect the file .c (proyect...add to proyect...file)

Sorry im mexican, i dont speak english Saludos.

marlo