What's new

C++ dx problem

Doomulation

?????????????????????????
Aye, i'm not the very best at c++ and i have troubles, so i thought i'd ask...

The problem's that i can't get c++ to compile any dx source. I've included the "include" directory as well as the "link" directory in the options. The documentation also says to include the link libraries, although i tried to include the libraries that was shown on the picture with no luck...

Is there something i'm doing wrong? If you wonder, i'm using c++ 6.0 enterprise and dx8
 
OP
Doomulation

Doomulation

?????????????????????????
PHP:
extern "C" BOOL PASCAL EXPORT LoadFile(char* File)
{
	IDirectMusicLoader8* m_pLoader;
 
	CoInitializeEx(NULL, 0);
	HRESULT hr = CoCreateInstance(
		CLSID_DirectMusicLoader,
		NULL,
		CLSCTX_INPROC, 
		IID_IDirectMusicLoader8,
		(void**)&m_pLoader);

	IDirectMusicSegment8 * m_pSegments[4];
 
	static WCHAR  wszNames[4][MAX_PATH] = {
		L"AudioPath1.sgt",
		L"AudioPath2.sgt",
		L"AudioPath3.wav",
		L"AudioPath4.sgt"
	};
 
	for (DWORD dwIndex = 0; dwIndex < 4; dwIndex++)
	{
		hr = m_pLoader->LoadObjectFromFile(
				CLSID_DirectMusicSegment,
				IID_IDirectMusicSegment8,
				wszNames[dwIndex],
				(void**) &m_pSegments[dwIndex]);
	}
}

Yes yes, i agree; i copyied and pasted this code directly from the documentation, and thus therefore, the argument is unneccesary, but i'm modifying it later.

And now, the compile errors:

C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(66) : error C2065: 'IDirectMusicLoader8' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(66) : error C2065: 'm_pLoader' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(66) : warning C4552: '*' : operator has no effect; expected operator with side-effect
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(68) : error C2065: 'CoInitializeEx' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(70) : error C2065: 'CLSID_DirectMusicLoader' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(73) : error C2065: 'IID_IDirectMusicLoader8' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(76) : error C2065: 'IDirectMusicSegment8' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(76) : error C2065: 'm_pSegments' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(76) : error C2109: subscript requires array or pointer type
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(76) : warning C4552: '*' : operator has no effect; expected operator with side-effect
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(87) : error C2227: left of '->LoadObjectFromFile' must point to class/struct/union
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(88) : error C2065: 'CLSID_DirectMusicSegment' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(89) : error C2065: 'IID_IDirectMusicSegment8' : undeclared identifier
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(91) : error C2109: subscript requires array or pointer type
C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(91) : error C2102: '&' requires l-value
 

icepir8

Moderator
OK. Here is what you need to do.

go to the tools, options, directories screen (where you added the include and lib directories. Move both of DX8 ones to the top of the list. It will search the top ones first. What is happening is that the VC++ default directories include older DX files and VC++ is trying to use them instead of the DX8 ones.
 
OP
Doomulation

Doomulation

?????????????????????????
I'm getting another error...

C:\Program\Microsoft Visual Studio\MyProjects\Doom Music Player\Doom Music Player.cpp(72) : error C2065: 'CoInitializeEx' : undeclared identifier

This function...is which header can i find it?
 
OP
Doomulation

Doomulation

?????????????????????????
Actually, I looked up that in the help and found a header, although when i included it, it still didn't work >_<

PHP:
...
#include <objbase.h>
...

Same error.
I also tried Project-->Settings-->Link-->"Object/library modules:"-->"ole32.lib"
Still no effect.
 
OP
Doomulation

Doomulation

?????????????????????????
Although that didn't work...i used the tutorials and included the link libraries and it worked ^_^
Thanks, now i can finally port some code of the player to c++ :D
 

Top