Link to home
Start Free TrialLog in
Avatar of iceblue_22
iceblue_22

asked on

errors while creating a DLL

Hi guys,

this is a very basic question for all you veterans in delphi.

I am creating a DLL in delphi tht I can't compile. I get an error message saying:

Unsatisfied forward or external declaration <procedurename>

wht does this mean???? and how do I fix the bug? right now I declare the function header at the top of the unit and also before the code in the implementation section. In my main project file I just list the name of the function under exports. Is this the right method for creating DLLs??

Also what does Self.<something> mean in delphi??? Is this a fucntion or type? how do we declare this in a project unit?

thanks,
ice
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pderuiter
pderuiter

k, in Delphi you have 2 "zones", an INTERFACE zone and an IMPLEMENTATION zone.
in the interface, you forward declare a function or procedure that you implement in the implementation zone.
If you put a function call in the interface zone, but not the implementation you will get this error.

straight from the help:

Within the implementation of a method, the identifier Self references the object in which the method is called.

In form form1 of type TForm1, self will reference form1
Avatar of iceblue_22

ASKER

Hi ziolko,

so far I have created two types of files
type 1: the main project file which looks like this

library sappdll;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes,
  define_types in 'define_types.pas',
  dicom in 'dicom.pas',
  analyze in 'analyze.pas',
  decompress in 'decompress.pas',
  lsjpeg in 'lsjpeg.pas',
  sapp_image_reader in 'sapp_image_reader.pas';

{$R *.RES}

exports
 read_afni_data,
 read_ecat_data,
 read_siemens_data,
 read_ge_data,
 read_voxbo_data,
 read_PAR_data,
 read_VFF_data,
 read_picker_data,
 write_dicom,
 read_tiff_data,
 read_dicom_data,
 clear_dicom_data,
 write_interfile_hdr,
 SaveAnalyzeHdr,
 OpenAnalyze,
 DecompressRLE8,
 DecompressRLE16,
 DecompressRLE16toRGB,
 DecompressGE,
 decompressJPEG8,
 decompressJPEG24,
 DecodeJPEG,
 DisplayImage;

begin
end.

type 2: units in which I have the code which looks like this

unit decompress;
//This unit decompresses images encoded by RunLengthEncoding (RLE), lossyJPEG or GE's proprietary compression algorithm
//Note: lossless JPEG are decoded by the separate unit 'lsjpeg.pas'

interface
{$ifdef Linux}
uses sysUtils,define_types,Qdialogs;
{$else}
uses dialogs,sysutils,windows,classes,jpeg,Graphics,define_types;
{$endif}
//declarations
procedure DecompressRLE8(var infp: file; var lOutputBuff: ByteP0;lSamplesPerPixel,lAllocSliceSz,lCompressOffset,lCompressSz: integer); stdcall; export;
procedure DecompressRLE16(var infp: file; var lOutputBuff: SmallIntP0;lImageVoxels,lCompressOffset,lCompressSz: integer); stdcall; export;
procedure DecompressRLE16toRGB(var infp: file; var lOutputBuffRGB: ByteP0;lImageVoxels,lCompressOffset,lCompressSz,lRedLUTOffset,lGreenLUTOffset,lBlueLUTOffset,lRedLUTSz,lGreenLUTSz,lBlueLUTSz: integer); stdcall; export;
procedure DecompressGE(var infp: file; var lOutputBuff: SmallIntP0;lImageStart,lImgWid,lImgHt,lGenesisPackHdr: integer); stdcall; export;
procedure decompressJPEG8 (lFilename: string; var lOutputBuff{gBuff8}: ByteP0; lAllocSliceSz,lImageStart{gECATposra[lSlice]}: integer); stdcall; export;
procedure decompressJPEG24 (lFilename: string; var lOutputBuff: ByteP0; lImageVoxels,lImageStart{gECATposra[lSlice]}: integer); stdcall; export;


implementation

//code for the above functions with exactly the same header as above.

end.

I belive I have done what you have said earlier...I think I have having problems with the way I put in my stdcall; and export; directives. Right now both of these only appear in the interface section, not the implementation section.

pderuiter,

righto so self is like this in java right? but from what all i have read I can't used "self.<something>" in a DLL...is this correct? if so what do i need to do to make sure that i get the same behaviour in the code without the self? right now I have commented out this like. my aim is to get this dll loaded into a VC++ enviroment so I use the functions in it there.

thanks guys for all your help.

ice







Hi ziolko,

so far I have created two types of files
type 1: the main project file which looks like this

library sappdll;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes,
  define_types in 'define_types.pas',
  dicom in 'dicom.pas',
  analyze in 'analyze.pas',
  decompress in 'decompress.pas',
  lsjpeg in 'lsjpeg.pas',
  sapp_image_reader in 'sapp_image_reader.pas';

{$R *.RES}

exports
 read_afni_data,
 read_ecat_data,
 read_siemens_data,
 read_ge_data,
 read_voxbo_data,
 read_PAR_data,
 read_VFF_data,
 read_picker_data,
 write_dicom,
 read_tiff_data,
 read_dicom_data,
 clear_dicom_data,
 write_interfile_hdr,
 SaveAnalyzeHdr,
 OpenAnalyze,
 DecompressRLE8,
 DecompressRLE16,
 DecompressRLE16toRGB,
 DecompressGE,
 decompressJPEG8,
 decompressJPEG24,
 DecodeJPEG,
 DisplayImage;

begin
end.

type 2: units in which I have the code which looks like this

unit decompress;
//This unit decompresses images encoded by RunLengthEncoding (RLE), lossyJPEG or GE's proprietary compression algorithm
//Note: lossless JPEG are decoded by the separate unit 'lsjpeg.pas'

interface
{$ifdef Linux}
uses sysUtils,define_types,Qdialogs;
{$else}
uses dialogs,sysutils,windows,classes,jpeg,Graphics,define_types;
{$endif}
//declarations
procedure DecompressRLE8(var infp: file; var lOutputBuff: ByteP0;lSamplesPerPixel,lAllocSliceSz,lCompressOffset,lCompressSz: integer); stdcall; export;
procedure DecompressRLE16(var infp: file; var lOutputBuff: SmallIntP0;lImageVoxels,lCompressOffset,lCompressSz: integer); stdcall; export;
procedure DecompressRLE16toRGB(var infp: file; var lOutputBuffRGB: ByteP0;lImageVoxels,lCompressOffset,lCompressSz,lRedLUTOffset,lGreenLUTOffset,lBlueLUTOffset,lRedLUTSz,lGreenLUTSz,lBlueLUTSz: integer); stdcall; export;
procedure DecompressGE(var infp: file; var lOutputBuff: SmallIntP0;lImageStart,lImgWid,lImgHt,lGenesisPackHdr: integer); stdcall; export;
procedure decompressJPEG8 (lFilename: string; var lOutputBuff{gBuff8}: ByteP0; lAllocSliceSz,lImageStart{gECATposra[lSlice]}: integer); stdcall; export;
procedure decompressJPEG24 (lFilename: string; var lOutputBuff: ByteP0; lImageVoxels,lImageStart{gECATposra[lSlice]}: integer); stdcall; export;


implementation

//code for the above functions with exactly the same header as above.

end.

I belive I have done what you have said earlier...I think I have having problems with the way I put in my stdcall; and export; directives. Right now both of these only appear in the interface section, not the implementation section.

pderuiter,

righto so self is like this in java right? but from what all i have read I can't used "self.<something>" in a DLL...is this correct? if so what do i need to do to make sure that i get the same behaviour in the code without the self? right now I have commented out this like. my aim is to get this dll loaded into a VC++ enviroment so I use the functions in it there.

thanks guys for all your help.

ice







I'll post some comments next week
ziolko.
I dont think you really need the export; directives. as long as your function is in the exports clause in your main unit, it will be useable.

Self can only be used within a method declared in a class. a "loose" method can't use self. i'm not sure what you want with "self".
pderuiter is right You dont need export clausule, and remember that in EXE wich will use this DLL functions headers olso must have stdcall. About Self delphi help says:  the identifier Self references the object in which the method is called.

so self is used in objects and its refernece of object to itself.

ziolko.
very probable that is the answer: A funciton with or without the stdcall: it will see them as different functions
iceblue_22:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to split points between ziolko and pderuiter
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer