Using Microsoft Visual C++ DLLs with C++Builder
Using Microsoft Visual C++ DLLs with C++Builder
As powerful as C++Builder is, the majority of DLLs developed and used within the software community are built using Visual C++. Therefore, chances are you will need to interface your C++Builder code with a Visual C++ DLL. Again, there are two ways for a DLL to attach to an application. Either it can be loaded in dynamically, or it can be loaded in statically if the LIB file associated to the DLL is linked at compile time. If that LIB file is a Microsoft LIB file, the DLL won't be able to load. The reason is because of the compatibility issues between the LIB file format for Visual C++ and C++Builder. Both vendors use different exporting conventions. Microsoft supports the Common Object Format File (COFF), whereas Borland uses the Object Model Format (OMF). Fortunately, there is a way to create a Borland OMF import library file that represents a Microsoft built DLL.
To create a Borland compatible .lib file for a Visual C++ DLL, you can use the COFF2OMF command-line tool from Borland, which resides in the Bin folder under C++Builder. COFF2OMF takes two arguments: the first is the source library's filename; and the second is the destination's filename.
Coff2Omf MyDll.lib MyDll_bor.lib
In this example, COFF2OMF will generate a new OMF library file called MyDll_bor.lib. Within your C++Builder project, be sure to link using this MyDll_bor.lib file as part of the project file listing.
NOTE
The COFF2OMF utility only works on lib files with simple exported C functions. If C++ classes are exported, it will not work.
If this doesn't work, you need to find out how the functions
are being exported and give them an alias that C++Builder will like. To do this,
first you should use Impdef.exe to create a definition file (or
.def file), which enables you to view all the exported functions' names
and ordinal numbers. Next, modify the exported functions in the .def
file, so the function looks like this:
Old export section
EXPORTS
_Add@8 =_Add @1 New export section
EXPORTS
Add=_Add@8
After you've made the changes to the library, save the .def file. Now you can use Implib.exe on this file to create a new library file that C++Builder should like. Implib.exe also takes two parameters: the destination and the source. For example
Implib MyDll.lib MyDll.def
Because you now have a library in C++Builder style, you should be able to include it in your project and use the DLL and .lib.
See the VCppProject folder on the CD-ROM that accompanies this book for the complete C++Builder project CallVCppDll.bpr. This uses the Visual C++ DLL mentioned previously.
Using Microsoft Visual C++ DLLs with C++Builder的更多相关文章
- FB Flash Builder 安装错误 ERROR: DW050: - Microsoft Visual C++ 2010 Redistributable Package (x86): Install failed
这个问题很可能是你的 Microsoft Visual C++ 2010 Redistributable Package (x86) 太新的缘故,所以无法安装成功,导致最终的失败. 在控制面板-程序和 ...
- Microsoft Visual Studio 2015 下载、注册、安装过程、功能列表、问题解决
PS:请看看回复.可能会有文章里没有提到的问题.也许会对你有帮助哦~ 先上一张最终的截图吧: VS2015正式版出了,虽然没有Ultimate旗舰版,不过也是好激动的说.哈哈.可能有的小伙伴,由于工作 ...
- Microsoft Visual SourceSafe 6.0 无法关联项目
最近遇到Microsoft Visual SourceSafe 6.0 安装好以后, 无法关联项目,导致无法进行版本控制,研究以后,发现需要运行一个程序,在安装目录下 ..\Visual Source ...
- Microsoft Visual Studio 文件识别及其用途简述
Microsoft Visual Studio IDE开发工具集,目前已推出多个不同版本,从之前的VC4.0到现在的VS2015,各个版本都会或多或少的功能或性能上的修改.提升,具体的改进地方可去官网 ...
- Microsoft Visual Studio PDB文件相关事宜
Microsoft Visual Studio PDB:调试的符号文件,程序数据库 (PDB) 文件保存着调试和项目状态信息,使用这些信息可以对程序的调试配置: 当以 /ZI 或 /Zi(用于 C/C ...
- Microsoft Visual Studio 2008 未能正确加载包“Visual Web Developer HTML Source Editor Package” | “Visual Studio HTM Editor Package”
在安装Microsoft Visual Studio 2008 后,如果Visual Studio 2008的语言版本与系统不一致时,比如:在Windows 7 English System 安装Vi ...
- AO安装需要Microsoft Visual Studio 2013?
从接触ArcGIS9.2到 10.4,在不断升级的 过程中,既给我们带来了很多惊喜,也带来一些麻烦,因为ArcGIS版本不兼容.出于体验,安装了ArcGIS Desktop10.4,AO也得升到10. ...
- please wait while windows configures microsoft visual studio professional 2013 [转载]
2016年5月30日 VS3013安装update 2以后,打开offie出现"please wait while windows configures microsoft visual s ...
- [转]SSAS没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG)) (Microsoft Visual Studio)的解决办法
转自:http://www.cnblogs.com/xvqm00/archive/2011/07/15/2107338.html 打开SSAS 数据源视图浏览数据时,提示 没有注册类别 (异常来自 H ...
随机推荐
- php+memcache高速缓存
原文地址:https://blog.csdn.net/qq_33571752/article/details/86494667 #在lnmp基础上修改 依赖libevent程序库 cd lnmp/ta ...
- Ubuntu开发环境配置
主要是: 源的更新 安装vim编辑器 远程登录xrdp相关配置 synergy symless键鼠共享配置 对新买的硬盘进行格式化和分区 vsftp环境搭建 gcc开发环境配置 qt5开发环境配置 m ...
- 查找searching
查找searching 在有序数列中查找某一个数据时候的算法设计 查找表的分类 静态查找表:只进行查找操作 动态查找表:不断的插入不存在,删除已存在 查找表的操作 查找.插入.删除 查找也叫检索,是根 ...
- FutureTask源码阅读
FutureTask功能用法 类结构 源码中详细说明了FutureTask生命周期状态及变化 /** * The run state of this task, initially NEW. The ...
- RabbitMQ基础命令rabbitmqctl
官网文档 https://www.rabbitmq.com/rabbitmqctl.8.html 一般操作命令后台管理页面都有的,部分没有(应用程序管理,和集群管理). 直接使用命令,必须配置环境变量 ...
- nginx配置的记录
基本使用 语法规则: location [=|~|~*|^~] /uri/ { - } = 开头表示精确匹配 ^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可.nginx不对url ...
- 用jquery和php实现ajax异步请求响应
ajax技术可以实现异步请求和响应,下面的是用jquery向一个php脚本发送异步请求,并得到响应. 第一步,准备好前台的html表单,和jquery实现的ajax请求 <html lang=& ...
- golang使用一个二叉树来实现一个插入排序
思路不太好理解,请用断点 package main import "fmt" type tree struct { value int left, right *tree } fu ...
- Account locked due to 25 failed logins
Account locked due to 25 failed logins pam_tally2 --user=ops #查看 pam_tally2 --user=ops --reset # ...
- BZOJ4400 TJOI2012桥(最短路+线段树)
首先找出任意一条1-n的最短路径.显然删除的边只有在该最短路上才会对最短路长度产生影响. 不会证明地给出一个找不到反例的结论:删除一条边后,新图中一定有一条1-n的最短路径上存在一条边x->y, ...