I create a *.bpl project BPL_A which contain a TForm subclass, say TForm_Sub.
The header file Form_Sub.h is like following:
class PACKAGE TForm_Sub : public TForm
{
...
};
extern PACKAGE TForm_Sub* Form_Sub;
The source file Form_Sub.cpp is like following:
TForm_Sub* Form_Sub;
__fastcall TForm_Sub::TForm_Sub( TComponent* Owner )
{
...
}
And I create another *.bpl project BPL_B to dynamically create TForm_Sub instance.
class PACKAGE SomeClass
{
public:
TForm* CreateUI( const AnsiString& name );
};
#include "Form_Sub.h"
TForm* SomeClass::CreateUI( const AnsiString& name )
{
if( name == xxx )
{
if( Form_Sub != NULL )
{
Form_Sub = new TForm_Sub( owner );
}
return Form_Sub;
}
}
I add BPL_A.bpi to Requires section of BPL_B. However, I get following link error when building BPL_B.
[ILINK32 Error] Error: Export SomeClass::CreateUI() in module xxx.OBJ references __fastcall TForm_Sub::TForm_Sub() in unit BPL_A]Form_Sub.
I can not figure out what is missing.