Jump to content

  • Log In with Google      Sign In   
  • Create Account

INITGUID: An Explanation


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 RWarden   Members   -  Reputation: 118

Like
Likes
Like

Posted 10 July 2000 - 10:51 AM

A lot of people (especially newbies) have this problem with DirectX. Here''s the deal: you have all your libraries set up and included in your program, yet you still get linkers errors for things like IID_IDirectDrawSurface7. To fix these errors, you need to #define INITGUID somewhere in your project. It must be defined before you include all the DirectX header files, and it must be defined only once per project (or you''ll get redefinition linker errors). The main source file is a good place to put this definition. However, you can run into problems when using pre-compiled headers. Let''s say you have one header file, precomp.h, that includes all of the Windows/DirectX header files. This pre-compiled header is included by every source file in your project and created through a file called precomp.cpp. Where do you put the INITGUID definition? Well, the first obvious place is either in precomp.h or precomp.cpp (which evaluates to exactly the same thing). However, if you do this, it will result in INITGUID being re-defined for every source file that uses the PCH. This can easily create thousands and thousands of linker errors. The second place would be in one of your source files, before you include the PCH. However, this won''t work either, because pre-compiled headers are pre-compiled and thus aren''t affected by #defines and such in the files they are included in. Putting #define INITGUID in a source file using a PCH will have no effect at all (and thus, you''ll have linker errors). The solution? It''s kind of a hack, and maybe there''s a better way (if you know of one, please let me know ). Create a new file for your project, name it initguid.cpp. Inside that file, #define INITGUID, then include all the DirectX header files. Do not set this file to use a pre-compiled header. Yes, you could simply #define INITGUID in any source file and make sure that source file doesn''t use your PCH (includes precomp.h without being set to use a precompiled header), but this would kind of defeat the purpose of having the PCH. Your initguid.cpp file will only be compiled once, and during full project rebuilds, and will fix all those damn linker errors. Hope that helps everyone who''s having trouble with that fun little aspect of DirectDraw . -RWarden (roberte@maui.net)

Sponsor:

#2 spurious interrupt   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 July 2000 - 11:50 AM

It is much easier NOT to define INITGUID.

Just add dxguid.lib to the list of libraries to link with.

#3 RWarden   Members   -  Reputation: 118

Like
Likes
Like

Posted 10 July 2000 - 12:27 PM

(Hits self in head)

I developed that while working in DirectX 3, before dxguid.lib. And now I feel stupid.. =)

-RWarden (roberte@maui.net)

#4 Shannon Barber   Moderators   -  Reputation: 1362

Like
Likes
Like

Posted 10 July 2000 - 09:36 PM

Is that why #define INIT_GUID is barely mentioned in any docs?

-Magmai Kai Holmlor

I am brazen and fear no flames.
(So long as I don't lose this Ring of Fire Protection +5)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS