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

编程入门 行业动态 更新时间:2024-10-15 22:23:11
本文介绍了Visual Studio 2008发布版本不装饰DLL导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

我的调试DLL构建导出方法带下划线。然而在我的版本DLL构建方法不装饰导致链接器错误在C + + B uilder。 (对于两种构建类型,请参见下面的dumpbin.exe的输出)

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

我已经管理它解决问题。 Borland工具implib将Visual Studio .lib文件转换为C ++ Builder .lib文件,可以添加下划线。

头文件methods.h b $ b

#ifndef METHODS_H #define METHODS_H #ifdef ENCRYPTION_EXPORTS #define DLLEXPORT __declspec(dllexport) #else #define DLLEXPORT __declspec(dllimport) #endif #ifdef __cplusplus externC { #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版本9.00.30729.01 版权所有(C)Microsoft Corporation。版权所有。 转储文件encryption.dll 文件类型:DLL 包含以下对encryption.dll的导出 00000000特征 50B8B22E时间日期戳日期11月30日13:18:38 2012 0.00版本 1序数基数 4函数数量 4数量名称 序数提示RVA名称 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) 摘要 5000 .data 1000 .idata 13000 .rdata 5000 .reloc 1000 .rsrc 64000 .text 2F000 .textbss

发布版本的Dumpbin.exe输出

dumpbin / EXPORTS encryption.dll

Microsoft PE Dumper版本9.00.30729.01 版权所有(C)Microsoft Corporation。版权所有。 转储文件encryption.dll 文件类型:DLL 包含以下对encryption.dll的导出 00000000特征 50B8BE14时间日期戳记十一月30日星期三14:09:24 2012 0.00版本 1序数基数 4函数数量 4数量名称 序数提示RVA名称 1 0 00001A10 DecryptString 2 1 000012C0 EncryptExit 3 2 00001370 EncryptInitialise 4 3 00001820 EncryptString 摘要 4000 .data 4000 .rdata 2000 .reloc 1000 .rsrc F000 .text

解决方案

这里是一篇关于调用约定和名称装饰。名称装饰可能会被您项目中的* .def文件覆盖。

I'm building a C++ DLL in Visual Studio 2008 to be used by a C application written in Borland C++ Builder 6.

My debug DLL build exports methods decorated with an underscore. However in my release DLL build the methods are not decorated causing linker errors in C++ Builder. (See below for output for dumpbin.exe for both build types)

I've checked the compiler options for both debug and release configuration and cannot see anything that might be causing this problem.

I've managed it get around the problem. The Borland tool implib, which converts Visual Studio .lib files to a C++ Builder .lib files, can add an underscore. But I would like to understand why the exports are not being decorated.

Header file 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 output for debug build

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 output for release build

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

解决方案

here is an article about calling conventions and name decoration. the name decoration may be overruled by a *.def file in your project.

更多推荐

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

本文发布于:2023-11-06 20:33:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564602.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   Studio   Visual   DLL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!