gpt4 book ai didi

c++ - Visual Studio 2008 发布版本不修饰 DLL 导出

转载 作者:太空宇宙 更新时间:2023-11-04 12:02:17 25 4
gpt4 key购买 nike

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

我的调试 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 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

最佳答案

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

关于c++ - Visual Studio 2008 发布版本不修饰 DLL 导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13648951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com