2009-05-24 7 views
0

Ich versuche, Code aus dem nVidia 9.5 SDK zu bauen, aber ich erhalte die folgenden Linkfehler:Linker Fehler in Visual C++ LNK2005, LNK2019 - nicht sicher, warum

>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) 

Ich habe keine Ahnung, warum ich bin Ich bekomme 99% sicher, dass ich meine Verzeichnisse richtig eingerichtet habe.

Zum Beispiel eine der Funktionen, die es nicht finden kann, ist TextureFactory :: CreateTextureFromFile, aber ich habe das Verzeichnis, in dem diese Funktion deklariert und definiert bereits in den Visual C++ - Einstellungen zum Include/source-Verzeichnis hinzugefügt.

Anfang der Datei sieht wie folgt aus:

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

Mehr zu dem Punkt, wenn ich # include „TextureFactory.h“ und # include „texturefactory.cpp“ am Anfang der Datei sagen, in dem ich bekomme diese Fehler, dann kann es keinen Raum für Mehrdeutigkeit geben, die Funktionen sind definiert und im Grunde kopiert und eingefügt in die gleiche Quelldatei erzeugt den Linker-Fehler, aber ich bekomme immer noch den Linker-Fehler.

Habe ich etwas übersehen?

+0

Bitte zeigen Sie den Anfang Ihrer Quelldatei an, um die Reihenfolge anzuzeigen, in der Sie die Header-Dateien einfügen (einschließlich texturfactory.cpp). – ChrisW

Antwort

2

Das passiert, weil:

1 Die Quelle der LIB wie gesagt fehlt tomzx oder Daniel, oder 2 Der LIB es in einer anderen Version von Visual C Try kompiliert wurde Ihre Datei wie ein erstellen .c (NOT a .cpp) im Editor, dann fügen Sie Ihrem Projekt die Datei .c hinzu (Projekt ... zum Projekt ... hinzufügen)

Entschuldigung, ich bin Mexikaner, ich spreche kein Englisch . Saludos.

2

Sie haben die Dateien im Ordner include/source hinzugefügt, aber was ist mit den Bibliotheken? Sieht eher wie ein Bibliotheksproblem aus (fehlende .lib).

Vielleicht müssen Sie auch Ihre Abhängigkeiten in Linker - Input auflisten.

LNK2005 bedeutet im Allgemeinen, dass zusätzliche Bibliotheken nicht korrekt verknüpft sind.

2

Sie haben wahrscheinlich vergessen, eine Verknüpfung zu einer der SDKs lib-Dateien herzustellen. Sie können dies in Ihren Projekteigenschaften unter Linker-> Input-> Additional Dependencies einstellen oder eine #pragma comment verwenden.