I had to brush up on my command-line parameters for cl, link, lib, and dumpbin today. It had been a little while since I had done this so I had to refresh my memory. The project dealt with a DLL generated by Delphi (the original source language was closest to Pascal/Delphi so I wrote a utility to convert Pascal rather than doing a massive conversion) and also generated C headers files and C unit test files at the same time. A while back they wanted a new DLL for a different project that used different functions from the original source. I was quite busy on another project but found enough time to make the new DLL. There was a problem with the initialization of one of the functions though.

In order to debug, I compiled the unit test but it wouldn't link directly to the DLL. I had to generate the .LIB and .EXP from the DLL file and I had to go back to the manuals to figure it out again. Fortunately I already had the .DEF file but I used dumpbin /exports to verify the list of functions. The command to build the .LIB file was: lib /def:myfake.dll /machine:IX86 /verbose

Command Prompt

It didn't take too long to generate the .LIB file and compile and link the unit test. And sure enough I found the problem in a minute. Since the end use for the DLL is a simulation system, when the DLL makes function calls to methods involving time there is a callback function that allows the simulation to provide the time information. The language conversion utility is not aware of special system functions that need extra initialization (it was a feature I always wanted to add but never got time to do and I've moved on to other departments since then). It turned out the only thing missing was to add the TIMER structure to the function block structure in the C header file and everything was fine.

Technorati tags: