?
Solved

errors while creating a DLL

Posted on 2003-02-19
11
Medium Priority
?
256 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:iceblue_22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 80 total points
ID: 7985861
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
 

Expert Comment

by:pderuiter
ID: 7988541
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
 

Author Comment

by:iceblue_22
ID: 7990026
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:iceblue_22
ID: 7990933
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
 
LVL 21

Expert Comment

by:ziolko
ID: 7995772
I'll post some comments next week
ziolko.
0
 

Expert Comment

by:pderuiter
ID: 8002888
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
 
LVL 21

Expert Comment

by:ziolko
ID: 8014413
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
 

Expert Comment

by:pderuiter
ID: 8043481
very probable that is the answer: A funciton with or without the stdcall: it will see them as different functions
0
 

Expert Comment

by:CleanupPing
ID: 9317174
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
 
LVL 10

Expert Comment

by:kacor
ID: 9928432
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question