C++Builder and VC DLL call each other solutions

Due to the different implementation details of MS and Borland (CodeGear) editors, the DLLS generated by them cannot be used with each other, which brings a lot of trouble in practice. Here’s how to fix the problem.

VC generation DLL, C++Builder call

Extern “C” extern “C” extern “C” Extern “C” __declspec(dllexport) int aFunc(int a); 2. Use the implib tool of C++Builder to generate the corresponding lib file of DLL. For example, implib -a xxx.lib xxx. DLL (note that implib must have the -A switch). After generating the lib file, C++Builder can use the lib file.

C++Builder generation DLL, VC call

Extern “C” extern “C” C++Builder Extern “C” __declspec(dllexport) int aFunc(int a); 2, C++Builder impdef tool to generate DLL corresponding def file. For example, impdef xxx.def xxx.dll.

Description:

Impdef. exe is a C++Builder tool that can be found in the installation directory.

2) Copy impdef.exe to a separate folder and copy the DLL file to this directory.

3) Create a bat file in this directory and enter impdef xxx.def xxx. DLL (XXX indicates the file name to be converted).

 

3. Open the xxx.def file with Notepad and delete the “_” before each function name. C/C++ code LIBRARY xxx. DLL EXPORTS __cppdebughook@2; __CPPdebugHook _aFunc @1 ; C/C++ code LIBRARY XXX.dll EXPORTS _cppdebughoo@ 2; __CPPdebugHook aFunc @1 ; _aFunc 4, use the VC LIB tool, according to the above def file generate LIB file. LIB /DEF: xxx.def. After the lib file is generated, the VC can use the lib file.

Description:

1) Lib. exe is the VC built-in, in the VC installation directory;

2) Copy lib.exe to the directory in step 2.

3) create a new bat file again, enter LIB /DEF: xxx. DEF, will be generated in the current directory in the VC LIB file. To sum up, the two tools developed DLL in mutual use, the main problem is the lib library problem, can solve this problem well.