I cannot find how to access a home made Package Library from an application. I use Codegear C++ builder 2007.
First I coded the Package and it produced a .bpl file. I copied it to a directory that can be found.
Then I made the application that needs the package. Nothing I tried caused the application to compile. The error messages I get say that there is an "...Error: Unresolved external 'A::getValue() const' referenced from D:\RAD PROJECTEN\BPL-TEST\TEST01APPLCATIE\DEBUG_BUILD\UNIT1.OBJ".
I now have the code as follows:
mylib.cpp:
mylib.h:
Unit1.cpp:
Unit1.h:
What is missing?
Regards, Alex
First I coded the Package and it produced a .bpl file. I copied it to a directory that can be found.
Then I made the application that needs the package. Nothing I tried caused the application to compile. The error messages I get say that there is an "...Error: Unresolved external 'A::getValue() const' referenced from D:\RAD PROJECTEN\BPL-TEST\TEST01APPLCATIE\DEBUG_BUILD\UNIT1.OBJ".
I now have the code as follows:
mylib.cpp:
Code:
#pragma hdrstop
#include "mylib.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//----------------------------------------------
#include "mylib.h"
class A;
A::A(int newa) : a(newa)
{
}
int A::getValue() const
{
return a;
}
void A::setValue(int newa)
{
a = newa;
}
Code:
#ifndef mylibH
#define mylibH
//---------------------------------------------------------------------------
class A;
class A
{
public:
A();
~A() {};
A(int newa);
int getValue() const;
void setValue(int newa);
private:
int a;
};
//----------------------------------------------
#endif
Code:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#include "mylib.h"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// Creates an object, A (from the library)
A test(50);
Form1->Caption = test.getValue();
}
Code:
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
What is missing?
Regards, Alex