Visual Studio 2008发布版本不装饰DLL导出

时间:2012-11-30 16:17:40

标签: c++ visual-studio-2008 dll dllexport

我正在Visual Studio 2008中构建一个C ++ DLL,供Borland C ++ Builder 6编写的C应用程序使用。

我的调试DLL构建导出用下划线装饰的方法。但是在我的发布DLL构建中,方法没有被修饰导致C ++ Builder中的链接器错误。 (请参阅下面的两种构建类型的dumpbin.exe输出)

我已经检查了调试和发布配置的编译器选项,但看不到可能导致此问题的任何内容。

我已经成功解决了这个问题。 Borland工具implib将Visual Studio .lib文件转换为C ++ Builder .lib文件,可以添加下划线。但我想了解为什么出口没有装饰。

标头文件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 encryption.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 encryption.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

1 个答案:

答案 0 :(得分:1)

这是一篇关于calling conventions and name decoration的文章。名称装饰可能会被项目中的* .def文件否决。