Comment exporter une fonction dans un package BPL ?
Bonjour,
Je souhaite créé un package BPL avec une fonction à appeler dynamiquement dans un autre programme C++.
Comment faire ceci avec c++ builder ?
J'y arrive en delphi, d'ailleurs l'exemple ici est simple : http://www.jcolibri.com/articles/pro...es_delphi.html
Quel est l'équivalent du mot clé delphi "exports" en c++ ?
J'ai essayé le code ci-dessous mais il ne fonctionne pas en compilant le package (uniquement si je crée explicitement une DLL).
J'ai des erreurs de link.
[ilink32 Erreur] Error: '__tpdsc__ Fmx::Forms::TForm' externe non résolu, référencé depuis C:\TEST\UNIT1.OBJ
...
...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| //---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <FMX.Controls.hpp>
#include <FMX.Forms.hpp>
#include <FMX.Controls.Presentation.hpp>
#include <FMX.StdCtrls.hpp>
#include <FMX.Types.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // Composants gérés par l'EDI
TLabel *Label1;
TLabel *Label2;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // Déclarations utilisateur
public: // Déclarations utilisateur
__fastcall TForm1(TComponent* Owner);
};
extern "C" __declspec(dllexport) void AppelEcran();
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void AppelEcran()
{
Form1 = new TForm1(NULL);
Form1->ShowModal();
delete Form1;
}
//-------------------------------------------------------------------------- |
Merci