1

Borland C++ Builder 6 で記述された C アプリケーションで使用される C++ DLL を Visual Studio 2008 で構築しています。

私のデバッグ DLL ビルドは、アンダースコアで装飾されたメソッドをエクスポートします。ただし、私のリリース DLL ビルドでは、メソッドが装飾されていないため、C++ Builder でリンカー エラーが発生します。(両方のビルド タイプの dumpbin.exe の出力については、以下を参照してください)

デバッグ構成とリリース構成の両方のコンパイラ オプションを確認しましたが、この問題の原因となっている可能性のあるものは何も見つかりません。

問題を回避することができました。Visual Studio .lib ファイルを C++ Builder .lib ファイルに変換する Borland ツールの implib では、アンダースコアを追加できます。しかし、輸出品が装飾されていない理由を理解したいと思います。

ヘッダー ファイル Methods.h

#ifndef METHODS_H
#define METHODS_H

#ifdef ENCRYPTION_EXPORTS
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C"
{
#endif

DLLEXPORT BOOL EncryptString(char *szPlain, char *szEncrypted);
DLLEXPORT BOOL DecryptString(char *szEncrypted, char *szPlain);
DLLEXPORT BOOL EncryptInitialise(void);
DLLEXPORT void EncryptExit(void);

#ifdef __cplusplus
}
#endif

#endif

デバッグ ビルドの Dumpbin.exe 出力

dumpbin /EXPORTS 暗号化.dll

Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file encryption.dll

File Type: DLL

  Section contains the following exports for encryption.dll

    00000000 characteristics
    50B8B22E time date stamp Fri Nov 30 13:18:38 2012
        0.00 version
           1 ordinal base
           4 number of functions
           4 number of names

    ordinal hint RVA      name

          1    0 000308F7 DecryptString = @ILT+2290(_DecryptString)
          2    1 00031635 EncryptExit = @ILT+5680(_EncryptExit)
          3    2 000303CF EncryptInitialise = @ILT+970(_EncryptInitialise)
          4    3 0003003C EncryptString = @ILT+55(_EncryptString)

  Summary

        5000 .data
        1000 .idata
       13000 .rdata
        5000 .reloc
        1000 .rsrc
       64000 .text
       2F000 .textbss

リリース ビルドの Dumpbin.exe 出力

dumpbin /EXPORTS 暗号化.dll

Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file encryption.dll

File Type: DLL

  Section contains the following exports for encryption.dll

    00000000 characteristics
    50B8BE14 time date stamp Fri Nov 30 14:09:24 2012
        0.00 version
           1 ordinal base
           4 number of functions
           4 number of names

    ordinal hint RVA      name

          1    0 00001A10 DecryptString
          2    1 000012C0 EncryptExit
          3    2 00001370 EncryptInitialise
          4    3 00001820 EncryptString

  Summary

        4000 .data
        4000 .rdata
        2000 .reloc
        1000 .rsrc
        F000 .text
4

1 に答える 1

1

呼び出し規約と名前の装飾に関する記事はこちらです。名前の装飾は、プロジェクトの *.def ファイルによって無効になる場合があります。

于 2012-11-30T16:37:02.863 に答える