急,调用dll时出现这样的错误,为什么?(20分)

  • 主题发起人 主题发起人 kmwap
  • 开始时间 开始时间
K

kmwap

Unregistered / Unconfirmed
GUEST, unregistred user!
[?][Linker Error] Unresolved external '_connect' referenced from D:/TEST/UNIT1.OBJ
 
connect声明了,但是没有实现吧。
 
kmwap:
你是不是使用的是dll静态调用?静态调用时若不将相应的.lib加入project中,会出现
此提示!
 
把你的代码贴出来
 
原来是声明不对,我已搞定
 
[Linker Error] 'D:/E.XCARD/APPUTILLIB/BIN/APPUTILLIB.LIB' contains invalid OMF record, type 0x21 (possibly COFF)
大家帮帮我,这个怎么回事?DLL是编译好没有错误的
 
用了vc的lib了
 
connect
stdcall
 
那怎样解决这个问题呢?楼上的能说清楚一点么?
 
偶也正在作这个,如果你使用的M$ VC的dll和Lib中间包含有OMF,需要先用BCB安装目录下Bin中有一个文件coff2omf.exe,用它可以把VC的lib库进行转换为BCB可用的,
有这几个exe文件可能你用的上,impdef.exe implib.exe
 
beachboy 你好,我已经用coff2omf.exe 把MS VC的Lib转过来了,但还是不能用,我想应该是我的方法不对。
问一个白痴问题,静态库,导入库,以及动态库它们的区别。
 
在BCB里调用静态库的函数好像就只要先包含函数的说明并把Lib加入工程中就可以了。
但是编译时出现这样的问题:
[Linker Error] Unresolved external 'UnloadShowInterface()' referenced from E:/DSX_LIB/UNIT_MAIN.OBJ
难道还是由于Lib的关系吗?
 
那就有可能是因为命名规则的问题,BCB是不认VC的命名的,如果是这样你就需要用impdef程序重新定义lib中的函数名称,然后在用implib重新生成新的lib,具体最好参考BCB5程序设计大全这本书!
 
Q: How to fix linker errors that say: "Invalid OMF record type 0x21 (possibly COFF)"

Answer
This error usually occurs when you try to link with a LIB file or an OBJ file that is not compatible with Borland's OMF file format. This typically happens when dealing with libraries from third party vendors. Often times, the third party vendor will supply you with a LIB file that is in Microsoft's COFF format. The Microsoft COFF format is incompatible with Borland's OMF format.
The best solution is to obtain Borland compatible files from the third party vendor. Unfortunately, many third party vendors will simply ignore you. If this happens to you, your choices are limited.
If the LIB file is an import library for a DLL, you can create a Borland compatible import library using Borland's IMPLIB tool. All you need todo
is pass IMPLIB the name of the DLL. IMPLIB will generate a Borland compatible import library. Link with that library instead of the one from the vendor. Another option is to use Borland's COFF2OMF tool on the Microsoft import library. I prefer to use IMPLIB if the DLL is available. For more details on how to call an MSVC DLL from BCB, see the article at http://www.bcbdev.com/articles/vcdll.htm.
Note:
--------------------------------------------------------------------------------
IMPLIB and COFF2OMF will only work if the library and DLL export plain, C functions. If they export C++ classes or mangled function names, then
you will get linker errors, or possibly errors while generating the Borland compatible import library. If you run into this problem, see the C++ DLL article at http://www.bcbdev.com/articles/vcdll2.htm.
--------------------------------------------------------------------------------


If the LIB file is a static library instead of an import library (static libraries contain real code, import libraries are just stubs for DLLs), then
the situation becomes more convoluted. You cannot link MSVC static libraries with your BCB project. You can't easily convert the library from COFF format to OMF either. Borland's COFF2OMF tool only works on import libraries. The only clean solution is to use MSVC to create a DLL or a COM object that wraps the static library. Create a DLL with MSVC that exports a wrapper function for each routine in the static library. If the static library contains C++ classes, then
you could be in for a rough ride. Consult the article at http://www.bcbdev.com/articles/vcdll2.htm. It describes how to wrap a C++ DLL with a Borland compatible DLL. Static C++ libraries are not quite the same, but they are very similiar. The techniques involved are practically the same.
If you have been given raw OBJs, then
you follow the same advice from the preceding paragraph regarding static libraries. Static libraries are more or less collections of OBJ files. So it makes sense that you would have to follow the same, rather unpleasant, course of action. Create an MSVC wrapper DLL for the code in the OBJ, and call the DLL from your BCB application.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
831
import
I
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部