Main Content

Overview of Internal Processes

Code Generation

The first step in the build process generates all source code and other supporting files needed to create the component. It also creates the main source file (mycomponent_dll.cpp) containing the implementation of each exported function of the DLL. The compiler additionally produces an Interface Description Language (IDL) file (mycomponent_idl.idl), containing the specifications for the component's type library, interface, and class, with associated GUIDs. (GUID is an acronym for Globally Unique Identifier, a 128-bit integer guaranteed always to be unique.)

Created next are the C++ class definition and implementation files (myclass_com.hpp and myclass_com.cpp). In addition to these source files, the compiler generates a DLL exports file (mycomponent.def) and a resource script.

Create Interface Definitions

The second step of the build process invokes the IDL compiler on the IDL file generated in step 1 (mycomponent_idl.idl), creating the interface header file (mycomponent_idl.h), the interface GUID file (mycomponent_idl_i.c), and the component type library file (mycomponent_idl.tlb). The interface header file contains type definitions and function declarations based on the interface definition in the IDL file. The interface GUID file contains the definitions of the GUIDs from all interfaces in the IDL file. The component type library file contains a binary representation of all types and objects exposed by the component.

C++ Compilation

The third step compiles all C/C++ source files generated in steps 1 and 2 into object code. One additional file containing a set of C++ template classes (mclcomclass.h) is included at this point. This file contains template implementations of all necessary COM base classes, as well as error handling and registration code.

Linking and Resource Binding

The fourth step produces the finished DLL for the component. This step invokes the linker on the object files generated in step 3 and the necessary MATLAB® libraries to produce a DLL component (mycomponent_1_0.dll). The resource compiler is then invoked on the DLL, along with the resource script generated in step 1, to bind the type library file generated in step 2 into the completed DLL.

Registration of the DLL

The final build step registers the DLL on the system, as described in Register COM Component.