Need help with .lib file

Started by
2 comments, last by andyborowicz 18 years, 1 month ago
Hello! I have written a simple application in WinAPI with a small usage of DirectX. And I encountered a problem... When I try to create a wave file object: CWaveFile wavFileObj = new CWaveFile(); The program doesn't compile and writes for this line: C:\Program Files\Microsoft Visual Studio\MyProjects\Button\button.cpp(23) : error C2440: 'initializing' : cannot convert from 'class CWaveFile *' to 'class CWaveFile' No constructor could take the source type, or constructor overload resolution was ambiguous Dunno what's up... but tried a static declaration: CWaveFile wavFileObj; And now it compiles with no errors or warnings. But during the linking it says: button.obj : error LNK2001: unresolved external symbol "public: __thiscall CWaveFile::CWaveFile(void)" (??0CWaveFile@@QAE@XZ) button.obj : error LNK2001: unresolved external symbol "public: __thiscall CWaveFile::~CWaveFile(void)" (??1CWaveFile@@QAE@XZ) What the...? My question is - do I need a special .lib file for the linker to understand CWaveFile? And WHY THERE IS NO reference guide for all the .lib files - so that I could check where this or that belongs? My include section is good, i think: #include <windows.h> #include <d3d9.h> #include <dsound.h> #include <DXUTsound.h> And I have added these .lib's for the linker: dsound.lib dxerr9.lib dxguid.lib d3dx9d.lib d3d9.lib dinput8.lib winmm.lib comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Please, anyone...?
Advertisement
assuming C++

CWaveFile wavFileObj = new CWaveFile();

that line should be:

CWaveFile *wavFileObj = new CWaveFile();

note the addition of the asterix.

-me
Quote:Original post by andyborowicz
And now it compiles with no errors or warnings. But during the linking it says:

button.obj : error LNK2001: unresolved external symbol "public: __thiscall CWaveFile::CWaveFile(void)" (??0CWaveFile@@QAE@XZ)
button.obj : error LNK2001: unresolved external symbol "public: __thiscall CWaveFile::~CWaveFile(void)" (??1CWaveFile@@QAE@XZ)

My question is - do I need a special .lib file for the linker to understand CWaveFile? And WHY THERE IS NO reference guide for all the .lib files - so that I could check where this or that belongs?


CWaveFile is not part of the DirectX library. Instead, it is part of the sample code that comes with DIrectX. If you want to use it, you need to compile it yourself. The code for CWaveFile is found in DXUTsound.cpp. Also, CWaveFile may depend on other classes in the sample code and you may have to add those too.

The documentation on MSDN generally tells you which header file and library you need for a particular function or class.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Thank you guys for help :) Need more...

As for the asterisk - it helped (the same linker errors though) - but it surprises me because in the samples, tutorials or books I have used, there was my version (without asterisk). Strange...

And the main problem. The first thing I did was to add the DXUTsound.cpp to the project. I thought #include <DXUTsound.cpp> was enough. But it isn't :(

c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxutsound.cpp(10) : warning C4005: 'STRICT' : macro redefinition
c:\program files\microsoft visual studio\vc98\include\windef.h(15) : see previous definition of 'STRICT'
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxstdafx.h(84) : warning C4068: unknown pragma
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxstdafx.h(85) : warning C4068: unknown pragma
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxstdafx.h(86) : warning C4068: unknown pragma
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxstdafx.h(87) : warning C4068: unknown pragma
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxstdafx.h(88) : warning C4068: unknown pragma
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxstdafx.h(89) : warning C4068: unknown pragma
c:\program files\microsoft directx sdk (december 2005)\samples\c++\common\dxut.h(11) : fatal error C1189: #error : "DXUT requires a Unicode build. See the nearby comments for details"

The warnings? Don't really know what's up. But the Unicode build frightens me :) Is my addition of DXUTsound.cpp correct? Or should I do it in a more complicated way? What do you mean by 'to compile it yourself'? And is the DXUT really the only way to work with wave files in DirectX???

This topic is closed to new replies.

Advertisement