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
iceblue_22Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ziolkoCommented:
typical DLL:

library std;

uses
  SysUtils,
  Classes;
{$R *.RES}

function SomeFunction:Integer; stdcall;
begin
  Result:=0;
end;

exports
  SomeFunction index 1 name 'SomeFunction';
 
begin
end.

ziolko.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pderuiterCommented:
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
0
iceblue_22Author Commented:
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







0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

iceblue_22Author Commented:
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







0
ziolkoCommented:
I'll post some comments next week
ziolko.
0
pderuiterCommented:
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".
0
ziolkoCommented:
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.
0
pderuiterCommented:
very probable that is the answer: A funciton with or without the stdcall: it will see them as different functions
0
CleanupPingCommented:
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.
0
kacorretiredCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.