[英]Unresolved external / procedure entry point could not be located in BPL
I have a class called TTextStream in an existing project that inherits from TFileStream .我在继承自TFileStream的现有项目中有一个名为TTextStream的 class 。 It had a set of overloaded operator<< and operator>> function as member functions.
它有一组重载的operator<<和operator>> function 作为成员函数。
class PACKAGE TTextStream : public TFileStream
Most recommendations instead say that you should write external functions for those operators and make them friends of the class in question to be able to access private and protected memebers.大多数建议相反,您应该为这些操作员编写外部函数,并使他们成为相关 class 的朋友,以便能够访问私有和受保护的成员。
So as part of going through and cleaning up the code I did this.因此,作为浏览和清理代码的一部分,我这样做了。
And example of a function added并添加了 function 的示例
TTextStream& __fastcall operator >>(TTextStream& ts, AnsiString& s);
The implementation is then in the .cpp as usual.然后像往常一样在.cpp中实现。
Then within the TTextStream class I added然后在我添加的TTextStream class
friend TTextStream& __fastcall operator >>(TTextStream& ts, AnsiString& s);
The project produces a C++ Builder package (BPL) , let's call it Foo.bpl .该项目产生一个C++ Builder package (BPL) ,我们称之为Foo.bpl 。 It compiled fine and I then went on to compile the next BPL package, Bar.bpl , that uses functionality from Foo.bpl .
它编译得很好,然后我继续编译下一个 BPL package, Bar.bpl ,它使用来自Foo.bpl的功能。
All these BPL's are outputed to the "default" folder, C:\Users\Public\Documents\Embarcadero\Studio\20.0\BLP所有这些 BPL 都输出到“默认”文件夹C:\Users\Public\Documents\Embarcadero\Studio\20.0\BLP
Foo.bpi is added under Requires in the Bar.bpl project. Foo.bpi添加在Bar.bpl项目的Requires下。
Upon building I got在建造时我得到了
[ilink32 Error] Error: Unresolved external '__fastcall operator >>(TTextStream&, System::AnsiStringT<0>&)' referenced from BLABLABLA.OBJ
If I tried to link statically with Foo.lib instead it works fine.如果我尝试与Foo.lib静态链接,它可以正常工作。 After some digging I come to the conclusion that the function hasn't been exported correctly to Foo.bpl .
经过一番挖掘,我得出的结论是 function 没有正确导出到Foo.bpl 。
As I understand it I have to use the PACKAGE macro for this so I add this to the definition in the .h file and the implementation in the .cpp file.据我了解,我必须为此使用PACKAGE宏,因此我将其添加到.h文件中的定义和.cpp文件中的实现中。
PACKAGE TTextStream& __fastcall operator <<(TTextStream& ts, const AnsiString& s);
I recompile Foo.bpl , I then compile Bar.bpl and it now compiles and links fine.我重新编译Foo.bpl ,然后编译Bar.bpl ,它现在可以正常编译和链接。 But Bar.bpl is a runtime and design time package and when I go to install it in the IDE a Windows message dialog pops up with basically the same message as before.
But Bar.bpl is a runtime and design time package and when I go to install it in the IDE a Windows message dialog pops up with basically the same message as before.
The procedure entry point @$blsh$qr11TTextStreamrx27System@%AnsiStringT$us$i0$% could not be located in the dynamic library C:\Users\Public\Documents\Embarcadero\Studio\20.0\BPL\Dcl\Bar.bpl
So it seems to complain about not finding a function, that seems to be exported in Foo.bpl in Bar.bpl ?所以它似乎抱怨没有找到 function,这似乎是在Bar.bpl的Foo.bpl中导出的?
Not quite sure what I'm missing.不太确定我错过了什么。 TDUMP seems to show it actually being exported.
TDUMP似乎表明它实际上正在被导出。
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl>tdump -oiEXTDEF Foo.bpl | grep TTextStream
File STDIN:
00050668 211 0000 __fastcall operator <<(TTextStream&, const char *)
000505D8 210 0001 __fastcall operator <<(TTextStream&, System::WideString&)
0005057C 209 0002 __fastcall operator <<(TTextStream&, System::AnsiStringT<0>&)
00051350 213 0003 __fastcall operator >>(TTextStream&, System::WideString&)
000506B0 212 0004 __fastcall operator >>(TTextStream&, System::AnsiStringT<0>&)
00051D6C 218 0009 __tpdsc__ TTextStream
00051D3C 217 00DB TTextStream::
00051A18 216 00DC TTextStream::operator =(TTextStream&)
00050150 207 00DD __fastcall TTextStream::TTextStream(System::AnsiStringT<0>&, unsigned short, TEOLMode)
0005157C 215 00DE TTextStream::TTextStream(TTextStream&)
000514F4 214 00DF __fastcall TTextStream::~TTextStream()
0005051C 208 00E0 __fastcall TTextStream::WriteEOL()
or without de-mangling或不拆线
EXPORT ord:0211='@$blsh$qr11TTextStreampxc'
EXPORT ord:0210='@$blsh$qr11TTextStreamrx17System@WideString'
EXPORT ord:0209='@$blsh$qr11TTextStreamrx27System@%AnsiStringT$us$i0$%'
EXPORT ord:0213='@$brsh$qr11TTextStreamr17System@WideString'
EXPORT ord:0212='@$brsh$qr11TTextStreamr27System@%AnsiStringT$us$i0$%'
EXPORT ord:0218='@$xp$11TTextStream'
EXPORT ord:0050='@TLangFormNode@SaveToASCII$qqrp11TTextStreamui'
EXPORT ord:0217='@TTextStream@'
EXPORT ord:0216='@TTextStream@$basg$qrx11TTextStream'
EXPORT ord:0207='@TTextStream@$bctr$qqrrx27System@%AnsiStringT$us$i0$%us8TEOLMode'
EXPORT ord:0215='@TTextStream@$bctr$qrx11TTextStream'
EXPORT ord:0214='@TTextStream@$bdtr$qqrv'
EXPORT ord:0208='@TTextStream@WriteEOL$qqrv'
I have also tested with other calling conventions to rule that out.我还测试了其他调用约定以排除这种情况。
As a secondary test I also created a small test case.作为辅助测试,我还创建了一个小测试用例。
A project producing a bpl with a Unit (functions.h/functions.cpp) added with a single function生成带有单元 (functions.h/functions.cpp) 的 bpl 的项目添加了单个 function
#ifndef __MYFUNCS__
#define __MYFUNCS__
#pragma package(smart_init)
PACKAGE int add(int a, int b)
#endif
that just adds the two numbers together, with the implementation in the.cpp file.这只是将两个数字相加,并在 .cpp 文件中实现。 Compile and linkk the BPL.
编译并链接 BPL。
Then I created a console app that required the bpl in question, included the header file with the function definition (functions.h), compile and it fails linking with the same error.然后我创建了一个控制台应用程序,它需要有问题的 bpl,包括 header 文件和 function 定义(functions.h),编译并且链接失败并出现相同的错误。 So I'm probably missing some minor obvious thing...
所以我可能错过了一些明显的小事......
All this is done using RAD Studio 10.3.2 and not using the classic compiler.所有这些都是使用RAD Studio 10.3.2完成的,而不是使用经典编译器。
After running into this a few times I finally found a way that seems to "fix" it.在遇到这种情况几次之后,我终于找到了一种似乎可以“修复”它的方法。 Several BPL projects some of which contain IDE components refused to install with the message "procedure entry point" when I for instance changed a namespace or something.
几个 BPL 项目,其中一些包含 IDE 组件在我更改命名空间或其他内容时拒绝安装并显示“过程入口点”消息。 Functions were exported correctly to the BPL and what finally made it able to install the new version of the component BPL was
函数已正确导出到 BPL,最终使它能够安装新版本的组件 BPL 的是
Installing after this gave the error, instead在此之后安装给出了错误,而不是
I have no idea why this works but it has worked fine for 5 projects now.我不知道为什么会这样,但现在 5 个项目都运行良好。 I'm guessing some cache or something is messing up for me.
我猜一些缓存或某些东西让我搞砸了。 Or perhaps the old BPL that is uninstalled first doesn't actually get removed entirely.
或者,可能首先卸载的旧 BPL 实际上并没有完全删除。
If anyone has any idea what is going on I would be happy for the info.如果有人知道发生了什么,我会很高兴获得这些信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.