Export Virtual Function Tables from a DLL

A virtual function table (VFT) is usually generated in the compilation unit that defines the first non-inline virtual function in a class. You can use the /Wvft option to find out which function that is. The object file that contains the definition for this function will also contain the VFT.

Once you know which object file contains the VFT, use CPPFILT to dump the symbols in the object file. One of these symbols will be the name of the VFT that you want to export.

After you have determined what the name of the VFT is, you can either use the output of CPPFILT directly in the DEF file or you can manually add an entry for the VFT in the DEF file.

An example of the symbols dumped by CPPFILT:

;From object file:  .\vf.obj

  ;PUBDEFs (Symbols available from object file):

    ;area::?getdim(double&,double&)

    ?getdim__4areaFRdT1

    ;area::_objectCount

    _objectCount__4area

    ;triangle::?__ct()

    ?__ct__8triangleFv

    ;rectangle::?getarea()

    ?getarea__9rectangleFv

    ;rectangle::_objectCount

    _objectCount__9rectangle

    ___vft9rectangle4area

    ;area::?__ct()

    ?__ct__4areaFv

    ;area::?setarea(double,double)

    ?setarea__4areaFdT1

    ;rectangle::?__ct()

    ?__ct__9rectangleFv

    ___vft8triangle4area

    ___vft4area

    ;triangle::_objectCount

    _objectCount__8triangle

    ;area::?getarea()

    ?getarea__4areaFv

    ;triangle::?getarea()

    ?getarea__8triangleFv

Example of VFTs in the Module Definition file:

LIBRARY

EXPORTS

;From object file:  .\vf.obj

  ;PUBDEFs (Symbols available from object file):

    ;rectangle::_objectCount

    _objectCount__9rectangle

    ___vft9rectangle4area

    ;rectangle::?__ct()

    ?__ct__9rectangleFv

    ___vft8triangle4area

    ___vft4area



Module Definition Files