In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How does C++ Builder call Visual C++ DLL? for this question, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Calling the DLL created by Visual C++ DLL using C++Builder is no more difficult than calling DLL built by C++Builder. First of all, Borland and Microsoft differ in the file format of OBJ and the imported library, Visual C++ uses the COFF library format, while Borland uses the OMF format.
This means that you cannot add a Microsoft-generated import library to a C++Builder project. Thanks to the utility Borland IMPLIB, differences in file formats have been overcome.
The two products are also different in connection name (linker name) habits.
This is the main obstacle for C++Builder to call Visual C++ DLL. Each function in DLL or OBJ has a connection name. The connector declares the function of the prototype with the connection name resolve during the connection. If the connector cannot find the function with the connection name it thinks the program needs, it will generate an unresolved external error (unresolved external error).
With regard to function connection names, Borland and Microsoft differ in the following two points:
1-Visual C++ sometimes modifies the exported _ _ stdcall function.
When 2-Borland C++Builder introduced this modified function, it was considered to be the _ _ cdecl function.
So why is this so important? Take the # 1 _ _ stdcall calling habit as an example. If you create a DLL with Visual C++, which contains a _ _ stdcall decorated function called MyFunction (), Visual C++ will give the function a connection name of _ MyFunction@4. When the Borland connector tries to solve the call to construct this function, it thinks it wants to find a function called MyFunction. Because the Visual C++ DLL import library does not contain a function called MyFunction, the Borland connector reports an unresolved external error, realizing that the function was not found.
The solution to these three problems depends on the compilation of Visual C++ DLL. I divided the whole process into two steps.
Step 1: identify the calling habits used in Visual C++ DLL in order to fight the naming convention entanglement, you must first determine the calling habits used by functions in DLL. You can determine this by looking at the header file of DLL. The function prototype in the DLL header file is as follows
Step 2: check the connection name in DLL if DLL uses the _ _ stdcall call habit in step 1, you need to further check DLL to determine the naming convention that Visual C++ used to create it. Visual C++ modifies the _ _ stdcall function by default, but if the programmers who write this DLL add a DEF file to their project, they can prevent naming decorations. If the supplier does not use DEF files, your union is a little more cumbersome.
The command line tool TDUMP allows you to check the connection name of the DLL export function. The next command that calls TDUMP for DLL.
TDUMP can report a lot of information about DLL. We are only interested in the exported functions of DLL. The-ee command option instructs TDUMP to list only export information. The-m switch tells TDUMP to display in the original format of the DLL function. Without the-m switch, TDUMP will try to convert the decorated function into a format that is easy for people to read. If the DLL is large, you should redirect the TDUMP output to a file (by appending > MYDLL.LST).
The test DLL output of TDUMP for source code listings An and B is as follows:
Bo Dump Version 5.0.16.4 Copyright (c) 1988, 1998 Borland International Display of File DLL.DLL EXPORT ord:0000='CdeclFunction' EXPORT ord:0002='UnknownFunction' EXPORT ord:0001='_StdCallFunction@4'
Notice the prefix underscore and suffix @ 4 on the _ _ stdcall function. _ _ cdecl and functions that do not specify how to call do not have any modifiers. If Visuall C++ DLL is compiled with the DEF file, the modifier on the _ _ stdcall function will not appear.
This is the answer to the question about how C++ Builder calls Visual C++ DLL. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.