![](/img/trans.png)
[英]Runtime link error: The procedure entry point glewInit@0 could not be located
[英]Unresolved external / procedure entry point could not be located in BPL
我在繼承自TFileStream的現有項目中有一個名為TTextStream的 class 。 它有一組重載的operator<<和operator>> function 作為成員函數。
class PACKAGE TTextStream : public TFileStream
大多數建議相反,您應該為這些操作員編寫外部函數,並使他們成為相關 class 的朋友,以便能夠訪問私有和受保護的成員。
因此,作為瀏覽和清理代碼的一部分,我這樣做了。
並添加了 function 的示例
TTextStream& __fastcall operator >>(TTextStream& ts, AnsiString& s);
然后像往常一樣在.cpp中實現。
然后在我添加的TTextStream class
friend TTextStream& __fastcall operator >>(TTextStream& ts, AnsiString& s);
該項目產生一個C++ Builder package (BPL) ,我們稱之為Foo.bpl 。 它編譯得很好,然后我繼續編譯下一個 BPL package, Bar.bpl ,它使用來自Foo.bpl的功能。
所有這些 BPL 都輸出到“默認”文件夾C:\Users\Public\Documents\Embarcadero\Studio\20.0\BLP
Foo.bpi添加在Bar.bpl項目的Requires下。
在建造時我得到了
[ilink32 Error] Error: Unresolved external '__fastcall operator >>(TTextStream&, System::AnsiStringT<0>&)' referenced from BLABLABLA.OBJ
如果我嘗試與Foo.lib靜態鏈接,它可以正常工作。 經過一番挖掘,我得出的結論是 function 沒有正確導出到Foo.bpl 。
據我了解,我必須為此使用PACKAGE宏,因此我將其添加到.h文件中的定義和.cpp文件中的實現中。
PACKAGE TTextStream& __fastcall operator <<(TTextStream& ts, const AnsiString& s);
我重新編譯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.
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
所以它似乎抱怨沒有找到 function,這似乎是在Bar.bpl的Foo.bpl中導出的?
不太確定我錯過了什么。 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()
或不拆線
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'
我還測試了其他調用約定以排除這種情況。
作為輔助測試,我還創建了一個小測試用例。
生成帶有單元 (functions.h/functions.cpp) 的 bpl 的項目添加了單個 function
#ifndef __MYFUNCS__
#define __MYFUNCS__
#pragma package(smart_init)
PACKAGE int add(int a, int b)
#endif
這只是將兩個數字相加,並在 .cpp 文件中實現。 編譯並鏈接 BPL。
然后我創建了一個控制台應用程序,它需要有問題的 bpl,包括 header 文件和 function 定義(functions.h),編譯並且鏈接失敗並出現相同的錯誤。 所以我可能錯過了一些明顯的小事......
所有這些都是使用RAD Studio 10.3.2完成的,而不是使用經典編譯器。
在遇到這種情況幾次之后,我終於找到了一種似乎可以“修復”它的方法。 幾個 BPL 項目,其中一些包含 IDE 組件在我更改命名空間或其他內容時拒絕安裝並顯示“過程入口點”消息。 函數已正確導出到 BPL,最終使它能夠安裝新版本的組件 BPL 的是
在此之后安裝給出了錯誤,而不是
我不知道為什么會這樣,但現在 5 個項目都運行良好。 我猜一些緩存或某些東西讓我搞砸了。 或者,可能首先卸載的舊 BPL 實際上並沒有完全刪除。
如果有人知道發生了什么,我會很高興獲得這些信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.