Delphi: Dynamically linking DirectX
Hi all,
I'm working on a Delphi project, and I'm using both OpenGL and DirectX as renderers. Recently, someone pointed out my program didn't startup on Windows NT4. I traced it to the fact that there are static links into DirectX 9, which is unavailable on Win NT4.
I really don't want to force people to use DirectX 9, or non-Win NT4, since OpenGL can be used in the program as an alternative. I'm using Clootie's DirectX Headers; how to do make sure it's linking dynamically to the DirectX dlls, instead of statically (and then crashing the app)? Or are there any others ways of using DirectX in Delphi (up-to-date please, I've already found tons of outdated projects).
Greetz,
DanielPharos
(PS. I've already send an email to Clootie about it some time ago, but I haven't gotten any response (yet?).)
(Edit: Delphi 7 by the way)
[Edited by - DanielPharos on September 19, 2007 5:13:38 AM]
If you haven't done so, open "Direct3D9.pas" and find this code (it's on top):
As the comment says, remove the dot to enable some kind of dynamic linking. [wink]
// Remove "dots" below to force some kind of dynamic linking{.$DEFINE DIRECT3D9_DYNAMIC_LINK}{.$DEFINE DIRECT3D9_DYNAMIC_LINK_EXPLICIT}
As the comment says, remove the dot to enable some kind of dynamic linking. [wink]
Yeah, I spotted those before, but since that's their ONLY mention in the entire code, I didn't think they'd do something. But OK, I've tried them, and unless I'm doing something wrong, that doesn't work... I'm still getting the error about d3d9.dll when trying to start the program (yes, I did a full rebuild).
I guess the only way to completely remove the dependency is to link the DLL's at runtime, i.e. by using LoadLibrary() and mapping the functions yourself. Perhaps it's easier to provide separate executables for DX and OpenGL, maybe with some stub application to select one automatically.
Hmm, I'll probably just write a quick program to convert all the static links into dynamic ones, using LoadLibrary. Weird; if that's going to work, why didn't Clootie use it in his files?
The stub program: I thought about it, but it kinda makes a mess out of things, especially if it's not absolutely necessary. I'll try using LoadLibrary first, thanks!
The stub program: I thought about it, but it kinda makes a mess out of things, especially if it's not absolutely necessary. I'll try using LoadLibrary first, thanks!
Note that dynamic linking is not the same as runtime linking. With dynamic linking, the code is loaded when your program starts but you cannot run without the existence of the DLL it refers to.
Perhaps this Wikipedia article explains it better than I can:
Linky
Perhaps this Wikipedia article explains it better than I can:
Linky
Clootie usually posts at http://www.pascalgamedevelopment.com/
You might be able to ask this question directly.
You might be able to ask this question directly.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement