Compiling the DirectX 8 SDK Samples with C++Builder

by Michael Fötsch
November 21, 2000 (Last Update: June 8, 2001)

Table of Contents

  1. Abstract
  2. Introduction
  3. Converting Visual C++ Projects
  4. Creating Import Libraries
  5. Updating the Include Path
  6. What else?
  7. References
  8. Code archive


This article is meant as an add-on to the article “Using DirectX with C++Builder” [6], 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 [1].


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.

Converting the Visual C++ Projects to C++Builder Projects

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:

The user interface of the Visual C++ project converter

(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:

The list of projects in the .dsw file

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:

Choosing between Debug and Retail configuration

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:

Messages generated during conversion

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

Creating Borland-compatible Import Libraries

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:

The user interface of the WinTools program

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” [6].

Updating the C++Builder Include Path

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:

The project options dialog of C++Builder

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:

The Folders dialog

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.

What else?

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” [6], which answers many general questions about using Visual C++ code with C++Builder.

References and Links

[1] Links to DirectX and C++Builder Graphics newsgroups
[2] Microsoft DirectX Developer Center
[3] Platform SDK downloads
[4] Borland web site
[5] DirectX tutorial links
[6] “Using DirectX with C++Builder”


Leave a Reply

Your email address will not be published. Required fields are marked *

Python and C++, GNU/Linux, computer stuff…