| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 52725 | 2004-12-28 05:12:00 | DirectX: Linker error with _IID_IDirectDraw4 | D. McG (3023) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 308177 | 2004-12-28 05:12:00 | Just wondering if there are any programmers out there who know a bit about DirectX. I am trying to compile a test application in C++ that uses the DirectDraw4 interface in DirectX versions 6.1 and above. I have included the ddraw.h header and windows.h, also defined WIN32 for the compiler's preprocessor. The application compiles okay, but when it comes to linking I get this error in BC5 (Borland C++): Error: Error: Unresolved external '_IID_IDirectDraw4' referenced from <Object file of application> Tracing back the error, I have found that the source is the QueryInterface call (shown below) after creating the DirectDraw object and before setting the so-called co-operation level and display mode: // Get DirectDraw4 interface if ((tmpDxSys->QueryInterface(IID_IDirectDraw4, (LPVOID *) &dxSys)) != DD_OK) return; where tmpDxSys is the (locally-created) pointer to the DirectDraw object created in the previous DirectDrawCreate step, and dxSys is the class member pointer to the same object using the DirectDraw4 interface (used in subsequent calls to create surfaces etc.) Borland C++ prepends the underscore to symbol names in their errors, so don't worry about the missing first underscore. Adding an underscore in produces compiler errors. The target application is a Win32 (GUI) application. Before adding all this DirectX stuff I had a basic Win32 window appearing, so everything else seems okay. I had obtained the code from a DirectDraw sample application ( ... \DDraw\Src\DDEx2\DDEx2.cpp) provided with the DirectX6.1 SDK that came from a CD in one of my books, and tailored parts of it to my application. The only difference is that they define WIN32_LEAN_AND_MEAN before including Windows.h, whereas I define WIN32. Examining ddraw.h, I notice that IID_IDirectDraw4 is declared in the following preprocessor block: #if defined( _WIN32 ) && !defined( _NO_COM ) DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF, 0xC2,0xCD,0x35 ); ... DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f, 0xd9,0x30,0xc5 ); ... #endif Does anyone have any idea as to why the linker isn't picking up the declaration of IID_IDirectDraw4? Any help would be appreciated. D. McG |
D. McG (3023) | ||
| 308178 | 2004-12-28 05:37:00 | could it be that you have more than 1 copy of ddraw.h and the linker is picking up the wrong one?? | robsonde (120) | ||
| 308179 | 2004-12-28 06:28:00 | Even though I also have the DirectX8.0 SDK installed as well (but in a different directory), I have copied the header files (for the DirectX 6.1 SDK) into a subdirectory of C:\BC5\Include, likewise the lib files into a subdirectory of C:\BC5\Include. DDraw.h is included as follows: #include <DirectX\ddraw.h> Since the angled brackets (as opposed to double quotes) points to the C:\BC5\Include directory and no other relevant environment variables are set apart from C:\BC5\Bin, I don't think the linker should have trouble here. Why would it only produce errors for this, and not DirectDrawCreate(), SetCooperativeLevel(), SetDisplayMode(), etc.? Thanks for the suggestion - one extra possibility to eliminate! |
D. McG (3023) | ||
| 308180 | 2005-01-05 11:20:00 | BUMPing - first suggestion that works earns the author a virtual chocolate fish. And no, I'm not removing DirectX functionality. Might try and have another stab at it tomorrow (actually later on today after I've had my sleep). -D. McG |
D. McG (3023) | ||
| 308181 | 2005-01-05 11:27:00 | what about putting the DEFINE_GUID( IID_IDirectDraw4 line in to the main source file. or you could try defining WIN32_LEAN_AND_MEAN in the same way as the example did. |
robsonde (120) | ||
| 308182 | 2005-01-24 02:11:00 | Defining WIN32_LEAN_AND_MEAN didn't make a difference, neither did the DEFINE_GUID line as given in the ddraw.h file. After reading a DirectX programming book it says to include the ddraw.lib file in the project itself. That made no difference with the 6.1 SDK, but when I tried replacing it with the DX8.1 SDK files I received a different error about the LIB file having an invalid OMF record. After toiling on the Internet, I found out that the LIB files for DX8.1 are only given in the COFF format, so I need the 'coff2omf' utility to convert this file (funnily enough, it didn't come with my Borland C++ 5 package). So anyway, back to the DX6.1 SDK since at the time Microsoft had the decency to provide copies of the LIB files for Borland compilers in the SDK. Anyway, your second suggestion subconsciously prompted me to trace back the DEFINE_GUID macro to the objbase.h header file, which deals with COM / OLE. So I simply took the underlying definition and pasted that in my source. Now it at least compiles and links okay, but there seems to be some sort of run-time error that aborts the program completely. I'll try and work through these errors, but in the meantime you've earned the virtual chocolate fish as promised: >=<<<°> Thanks robsonde :) -D. McG |
D. McG (3023) | ||
| 308183 | 2005-01-24 02:38:00 | www.gamedev.net maybe a post to the forum linked above will help you. BTW I only work in OPENGL but this forum is run by the same dude and the OPENGL one is very good. |
robsonde (120) | ||
| 308184 | 2005-01-24 02:59:00 | That's horrible :yuck: I thought PostScript was bad enough. But I'd take things like this: 0.25 inch 0 rmoveto 90 rotate hor nstr cvs dup stringwidth pop 2 div neg 0 rmoveto show 90 neg rotate any time. :cool: |
Graham L (2) | ||
| 308185 | 2005-01-24 07:27:00 | I got one reply in a newsgroup where i posted this question. Look at <initguid.h> and search for it in one of the DShow groups like microsoft.public.win32.programmer.directx.video on Google Groups if you're still confused. See if your ISP has newsgroups, and join the above newsgroup. |
Speedy Gonzales (78) | ||
| 1 | |||||