by Michael Fötsch
November 21, 2000 (Last Update: June 8, 2001)
Table of Contents
- Converting Visual C++ Projects
- Creating Import Libraries
- Updating the Include Path
- What else?
- Code archive
This article is meant as an add-on to the article “Using DirectX with C++Builder” , which is also available on this site. This article deals specifically with the DirectX 8 SDK. I’m currently in the process of writing this article, so new information will be added. In the meantime, this article–along with the other article mentioned before–should answer many of the questions that are frequently asked about DirectX 8 and C++Builder in the Borland newsgroups .
Many Borland users are confused by the fact that the new DirectX 8 SDK does not ship with Borland-compatible link libraries. I haven’t had much time to play around with the DirectX 8 SDK. However, I have succeeded in compiling some of the Direct3D samples with C++Builder–and it took me only a few minutes.
What I like about the DirectX 8 SDK is that it comes with Visual C++ workspace (.dsw) files that make it easy to create C++Builder projects for the samples. C++Builder 5 (I don’t know about earlier versions) comes with a utility that converts .dsw and .dsp files to C++Builder project files. This utility is available from the Tools menu in the C++Builder IDE. You can also start it by double-clicking on the file vctobpru.exe in the CBuilderbin folder. To create a C++Builder project group for all Direct3D samples, for example, you would convert the file <Dx8VcSdk>samplesmultimediadirect3dd3d.dsw. See Figure 1 below:
(Thanks to Matt Crawford for providing the screenshots from the English version of C++Builder!)
Next, you choose one of the individual projects that you wish to convert. Unfortunately, there is no way to select multiple projects at a time. See Figure 2:
Each of the Visual C++ projects stores two configurations: Debug and Retail. Usually, I choose the Debug configuration when converting Visual C++ projects. However, you can go from Debug to Retail at a later time by setting the project options from the C++Builder IDE. See Figure 3:
After you press the “Convert” button, the project is converted. You’ll receive a few warnings about Visual C++ project options that can’t be converted. You can ignore these warnings. See Figure 4:
When you convert a .dsw file that contains more than one project (like d3d.dsw), make sure to convert all of the projects before opening the .bpg file that is created. Otherwise, C++Builder will complain about missing project files and remove the other projects from the project group.
After you’ve used the conversion utility, you will find the file d3d.bpg in the <Dx8VcSdk>samplesmultimediadirect3d folder. Open this file
In this section, I will explain how to use the Coff2Omf utility to create Borland-compatible import libraries (.lib files) from the libraries that ship with the DirectX 8 SDK.
To make working with the Coff2Omf utility (and all other command-line utilities that come with C++Builder) easier, you should first build the WinTools example, which can be found in the CBuilderExamples folder. Next, fire up the utility and go to the “Coff2omf” tab. Click the “Browse” button and select the file <Dx8VcSdk>libd3d8.lib (or whatever library you need). Click the “Run” button as shown in Figure 5:
Coff2Omf creates the file d3d8OMF.lib. Using Windows Explorer, go to the <Dx8VcSdk>lib folder and create the sub-folder “borland”. Copy the newly created .lib file to that folder and remove the “OMF” from its file name. Now, the path to the Borland-compatible d3d8.lib should be <Dx8VcSdk>libborlandd3d8.lib.
I’m quite sure that there are some files that can’t be converted using Coff2Omf.exe. For these files, generate an import library from the DLL by using the ImpLib utility. The ImpLib utility can also be accessed through the WinTools program. If the .lib file in question is a static library, you can’t create a Borland-compatible .lib file. That’s the sad truth…
For more information about the ImpLib utility, see also the article “Using DirectX with C++Builder” .
You should update the include path and the library path of the C++Builder project so that the compiler finds all .h files (and uses the correct versions) and the linker finds all .lib files (and uses the correct versions). To do this, open the Project Options dialog by choosing “Project | Options” from the menu. Go to the “Directories/Conditionals” tab as shown in Figure 6:
Add <Dx8VcSdk>include to the include path and <Dx8VcSdk>libborland to the library path. Make sure that these two paths are the first paths in their respective edit box. If you clicked the ellipses (“…”) button to open the Folders dailog, use the Up button as shown in Figure 7 so that the paths appear at the top of the list:
Now you should be able to compile the project. I only tested with a few of the Direct3D samples. I’m sure that there are some projects that won’t compile that smoothly. However, I’ll reserve that for the next update of this article.
I hope this article was of help. The article will be updated as soon as I have some time to add new material. If you have any questions, answers, or comments, feel free to e-mail me! See also “Using DirectX with C++Builder” , which answers many general questions about using Visual C++ code with C++Builder.
 Links to DirectX and C++Builder Graphics newsgroups
 Microsoft DirectX Developer Center
 Platform SDK downloads
 Borland web site
 DirectX tutorial links
 “Using DirectX with C++Builder”