0

I have code in a Delphi BPL and want to use it in C++ Builder. However, it doesn't work for me.

Here is what I have done:

(1) The Delphi BPL package:

package PackageNameHere;

{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS ON}
{$RANGECHECKS ON}
{$REFERENCEINFO OFF}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESCRIPTION '...'}
{$IMPLICITBUILD OFF}

.........
contains
  hcg_employeeAuth in 'Src\hcg_employeeAuth.pas';

(2) In the package options, I have enabled "Create all C++ Builder files"

(3) In the C++ Builder form, where the code should be used:

#include <vcl.h>
#pragma hdrstop
....................................
#include <hcg_employeeAuth.hpp>
#pragma package(smart_init)
#pragma resource "*.dfm"
....................................
void __fastcall TDLG_Main::FileNew1Execute(TObject *Sender)
{
  if (ThcgEmployeeAuth::Authentificate(__classid(ThcgEmployeeAuth))) {
     // ...
  }
}

(4) In the options of the C++ Builder project, I have

  • disabled: dynamic RTL
  • disabled: use runtime packages
  • in the packages section, checked the package, so it will used
  • added the path to the DCU/PAS and BPL everywhere... but it doesn't work.

I get the following error message during the Linker process:

ILINK32 Error: Cannot resolve external 'Hcg_employeeAuth::ThcgEmployeeAuth::' referenced by ....\main.obj

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Daniel Marschall
  • 3,739
  • 2
  • 28
  • 67
  • 1
    You can't disable runtime packages and then use a runtime package. – Ken White Oct 17 '16 at 15:59
  • @KenWhite: Ok, among other things, I also tried that: I have enabled "Use runtime packages", and have added the string "PackageNameHere" (ofc my real package name) in the list. The error message is then "PackageNameHere.bpl" cannot be opened. – Daniel Marschall Oct 17 '16 at 16:08
  • A package is, deep down inside, a DLL, so what applies to DLLs applies to BPL files too: the Windows system must be able to find the DLL. So your best bet is to put it in a directory in the path. Also the .bpi or whatever files C++Builder uses must be findable by Windows and/or by the IDE. – Rudy Velthuis Oct 17 '16 at 17:33
  • @RudyVelthuis the linker error has nothing to do with the BPL file itself, which is a run-time file, not a compile-time file. The BPI file is the compile-time import lib for the BPL file, so make sure the BPI file has been added to the project. – Remy Lebeau Oct 17 '16 at 18:45
  • @Remy: you're right, the linker needs to find the BPI file. But the BPL must be findable later to run anyway. – Rudy Velthuis Oct 17 '16 at 20:23
  • The BPI files exists in the directory PackageNameHere\PackageNameHere.bpi . But since I have added the directory PackageNameHere\ in every possible location in the C++ builder project's settings, I do not know why it can't be found. Also, will the BPL code be included in the EXE (since that is what I want to achieve)? – Daniel Marschall Oct 18 '16 at 06:50

0 Answers0