Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-03

FPC and Profiling software

20 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Does anybody know of any profiling software I can use with FPC? I'm mainly developing under Linux, but have a virtual Win2000 session as well, so Windows or Linux software will do.

I'm trying to detect where bottlenecks occur in my code.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys

Hi,

Doing some searching in the mailing list archives it seems I can use 'gprof' for profiling. Anybody got a tutorial or wiki page explaining it's usage with FPC programs?

Graeme.

Graeme Geldenhuys wrote 16 lines
Hi, Does anybody know of any profiling software I can use with FPC? I'm mainly developing under Linux, but have a virtual Win2000 session as well, so Windows or Linux software will do. I'm trying to detect where bottlenecks occur in my code. Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Codebue Fabio - P-Soft
to Graeme Geldenhuys

This is my UDF source

library pudf;
  {$mode objfpc}{$H+}
uses
  Classes;
function pround(var valore: real; ndec: integer):real;export;
var
  i: integer;
  risultato: real;
  ndivisore: integer;
begin
  risultato:= valore;
  ndivisore:= 1;
  for i:= 1 to ndec do
  begin
    risultato:= risultato*10;
    ndivisore:= ndivisore*10;
  end;
  result:= round(risultato)/ndivisore;
end;
exports
  pround name 'pround';
begin
end.

but after insert into my fdb with instruction

DECLARE EXTERNAL FUNCTION pround
DOUBLE PRECISION, INTEGER
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'pround' MODULE_NAME 'pudf';

if I use it with an instruction like this

select round(123.1233, 2) as nrounded from rdb$database

I have back this error

Invalid token.
invalid request BLR at offset 59.
function PROUND is not defined.
module name or entrypoint could not be found.

do you have some idea regarding this error?

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Reply by email

Michael Van Canneyt
to Codebue Fabio - P-Soft
Codebue Fabio - P-Soft wrote 48 lines
This is my UDF source library pudf; {$mode objfpc}{$H+} uses Classes; function pround(var valore: real; ndec: integer):real;export; var i: integer; risultato: real; ndivisore: integer; begin risultato:= valore; ndivisore:= 1; for i:= 1 to ndec do begin risultato:= risultato*10; ndivisore:= ndivisore*10; end; result:= round(risultato)/ndivisore; end; exports pround name 'pround'; begin end. but after insert into my fdb with instruction DECLARE EXTERNAL FUNCTION pround DOUBLE PRECISION, INTEGER RETURNS DOUBLE PRECISION BY VALUE ENTRY_POINT 'pround' MODULE_NAME 'pudf'; if I use it with an instruction like this select round(123.1233, 2) as nrounded from rdb$database I have back this error Invalid token. invalid request BLR at offset 59. function PROUND is not defined. module name or entrypoint could not be found. do you have some idea regarding this error?

Where did you put the library, what is the library name ?

Michael.

Reply by email

Jeff Pohlmeyer
Graeme Geldenhuys wrote
I'm trying to detect where bottlenecks occur in my code.

On Linux, you can get some interesting information with something like this:

% valgrind --tool=callgrind [YOUR_APP] [YOUR_ARGS] % callgrind_annotate --auto=yes --inclusive=yes > callgrind.log

And then have a look at "callgrind.log"

To use this, just be sure you do NOT compile your app with -pg !

More info at http://valgrind.org/

- Jeff

Reply by email

Codebue Fabio - P-Soft
to Michael Van Canneyt: Where did you put the library, what is the library name ? Michael.

I create a pudf.dll library an put in UDF subdirectory of firebird installation (where you can find other UDFs)

after this I use IBExpert to run the script

DECLARE EXTERNAL FUNCTION pround
DOUBLE PRECISION, INTEGER
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'pround' MODULE_NAME 'pudf';

it run ok, I find another udf under functions category with paremeter set correctly

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Earlier message 64 lines
-----Original Message----- From: On Behalf Of Michael Van Canneyt Sent: Thursday, March 13, 2008 9:52 AM To: ; FPC-Pascal users discussions Subject: Re: [fpc-pascal] Firebird UDF On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > This is my UDF source > > library pudf; > {$mode objfpc}{$H+} > uses > Classes; > > function pround(var valore: real; ndec: integer):real;export; > var > i: integer; > risultato: real; > ndivisore: integer; > begin > risultato:= valore; > ndivisore:= 1; > for i:= 1 to ndec do > begin > risultato:= risultato*10; > ndivisore:= ndivisore*10; > end; > result:= round(risultato)/ndivisore; > end; > > exports > pround name 'pround'; > > begin > end. > > but after insert into my fdb with instruction > > DECLARE EXTERNAL FUNCTION pround > DOUBLE PRECISION, INTEGER > RETURNS DOUBLE PRECISION BY VALUE > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > if I use it with an instruction like this > > select round(123.1233, 2) as nrounded from rdb$database > > I have back this error > > Invalid token. > invalid request BLR at offset 59. > function PROUND is not defined. > module name or entrypoint could not be found. > > do you have some idea regarding this error? Where did you put the library, what is the library name ? Michael.

Reply by email

Michael Van Canneyt
to Codebue Fabio - P-Soft
Codebue Fabio - P-Soft wrote 12 lines
I create a pudf.dll library an put in UDF subdirectory of firebird installation (where you can find other UDFs) after this I use IBExpert to run the script DECLARE EXTERNAL FUNCTION pround DOUBLE PRECISION, INTEGER RETURNS DOUBLE PRECISION BY VALUE ENTRY_POINT 'pround' MODULE_NAME 'pudf'; it run ok, I find another udf under functions category with paremeter set correctly
This is normal; the above just inserts a record in the metadata tables;
Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ?

Michael.

Show quoted text 91 lines
Codebue Fabio .-----------------------------. _ \ __| _|| __/____|\__ \ _ \ _| _| _| ____/\___/_| \__| P-Soft di Codebue Fabio & C. sas via B.Storti, 19 24060 - Chiuduno - BG Italy Phone: +39.030.839435 Fax: +39.030.5100306 Mobile: +39.348.3515786 .-----------------------------. Web : www.p-soft.biz EMail: -----Original Message----- From: On Behalf Of Michael Van Canneyt Sent: Thursday, March 13, 2008 9:52 AM To: ; FPC-Pascal users discussions Subject: Re: [fpc-pascal] Firebird UDF On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > This is my UDF source > > library pudf; > {$mode objfpc}{$H+} > uses > Classes; > > function pround(var valore: real; ndec: integer):real;export; > var > i: integer; > risultato: real; > ndivisore: integer; > begin > risultato:= valore; > ndivisore:= 1; > for i:= 1 to ndec do > begin > risultato:= risultato*10; > ndivisore:= ndivisore*10; > end; > result:= round(risultato)/ndivisore; > end; > > exports > pround name 'pround'; > > begin > end. > > but after insert into my fdb with instruction > > DECLARE EXTERNAL FUNCTION pround > DOUBLE PRECISION, INTEGER > RETURNS DOUBLE PRECISION BY VALUE > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > if I use it with an instruction like this > > select round(123.1233, 2) as nrounded from rdb$database > > I have back this error > > Invalid token. > invalid request BLR at offset 59. > function PROUND is not defined. > module name or entrypoint could not be found. > > do you have some idea regarding this error? Where did you put the library, what is the library name ? Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Codebue Fabio - P-Soft
to Michael Van Canneyt

I try with pudf.dll module name, I try to change function name ... I try a lot of things...
sigh a so stupid UDF, and I can't create it...

mmm

I'm using firebird 2.0.3 in windows vista environment. pudf was compiled with fpc 2.0.4 and created with lazarus 0.9.22

sigh!

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Earlier message 121 lines
-----Original Message----- From: On Behalf Of Michael Van Canneyt Sent: Thursday, March 13, 2008 10:24 AM To: FPC-Pascal users discussions Subject: RE: [fpc-pascal] Firebird UDF On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > I create a pudf.dll library an put in UDF subdirectory of firebird > installation (where you can find other UDFs) > > after this I use IBExpert to run the script > > DECLARE EXTERNAL FUNCTION pround > DOUBLE PRECISION, INTEGER > RETURNS DOUBLE PRECISION BY VALUE > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > it run ok, I find another udf under functions category with paremeter set > correctly This is normal; the above just inserts a record in the metadata tables; Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ? Michael. > > Codebue Fabio > .-----------------------------. > _ \ __| _|| > __/____|\__ \ _ \ _| _| > _| ____/\___/_| \__| > > P-Soft di Codebue Fabio & C. sas > via B.Storti, 19 > 24060 - Chiuduno - BG > Italy > Phone: +39.030.839435 > Fax: +39.030.5100306 > Mobile: +39.348.3515786 > .-----------------------------. > Web : www.p-soft.biz > EMail: > > -----Original Message----- > From: > On Behalf Of Michael Van > Canneyt > Sent: Thursday, March 13, 2008 9:52 AM > To: ; FPC-Pascal users discussions > Subject: Re: [fpc-pascal] Firebird UDF > > > > On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > > > This is my UDF source > > > > library pudf; > > {$mode objfpc}{$H+} > > uses > > Classes; > > > > function pround(var valore: real; ndec: integer):real;export; > > var > > i: integer; > > risultato: real; > > ndivisore: integer; > > begin > > risultato:= valore; > > ndivisore:= 1; > > for i:= 1 to ndec do > > begin > > risultato:= risultato*10; > > ndivisore:= ndivisore*10; > > end; > > result:= round(risultato)/ndivisore; > > end; > > > > exports > > pround name 'pround'; > > > > begin > > end. > > > > but after insert into my fdb with instruction > > > > DECLARE EXTERNAL FUNCTION pround > > DOUBLE PRECISION, INTEGER > > RETURNS DOUBLE PRECISION BY VALUE > > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > > > if I use it with an instruction like this > > > > select round(123.1233, 2) as nrounded from rdb$database > > > > I have back this error > > > > Invalid token. > > invalid request BLR at offset 59. > > function PROUND is not defined. > > module name or entrypoint could not be found. > > > > do you have some idea regarding this error? > > Where did you put the library, what is the library name ? > > Michael. > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Graeme Geldenhuys
to Jeff Pohlmeyer: On Linux, you can get some interesting information with something like this: % valgrind…

Thanks Jeff.

That seems to work fine with my project under Linux. Now I only need to learn the format and meaning of all the numbers in callgrind.log file. But I'm sure the website or man pages will give info on that.

Thanks again...

Regards,
- Graeme -

Jeff Pohlmeyer wrote 21 lines
Graeme Geldenhuys wrote: > I'm trying to detect where bottlenecks occur in my code. On Linux, you can get some interesting information with something like this: % valgrind --tool=callgrind [YOUR_APP] [YOUR_ARGS] % callgrind_annotate --auto=yes --inclusive=yes > callgrind.log And then have a look at "callgrind.log" To use this, just be sure you do NOT compile your app with -pg ! More info at http://valgrind.org/ - Jeff _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

zaher dirkey
to Codebue Fabio - P-Soft: I try with pudf.dll module name, I try to change function name ... I try a lot of…

try to add "cdecl"

|    function pround(var valore: real; ndec: integer):real; cdecl; export;

On Thu, Mar 13, 2008 at 11:43 AM, Codebue Fabio - P-Soft <

Show quoted text 163 lines
wrote: I try with pudf.dll module name, I try to change function name ... I try a lot of things... sigh a so stupid UDF, and I can't create it... mmm I'm using firebird 2.0.3 in windows vista environment. pudf was compiled with fpc 2.0.4 and created with lazarus 0.9.22 sigh! Codebue Fabio .-----------------------------. _ \ __| _|| __/____|\__ \ _ \ _| _| _| ____/\___/_| \__| P-Soft di Codebue Fabio & C. sas via B.Storti, 19 24060 - Chiuduno - BG Italy Phone: +39.030.839435 Fax: +39.030.5100306 Mobile: +39.348.3515786 .-----------------------------. Web : www.p-soft.biz EMail: -----Original Message----- From: On Behalf Of Michael Van Canneyt Sent: Thursday, March 13, 2008 10:24 AM To: FPC-Pascal users discussions Subject: RE: [fpc-pascal] Firebird UDF On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > I create a pudf.dll library an put in UDF subdirectory of firebird > installation (where you can find other UDFs) > > after this I use IBExpert to run the script > > DECLARE EXTERNAL FUNCTION pround > DOUBLE PRECISION, INTEGER > RETURNS DOUBLE PRECISION BY VALUE > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > it run ok, I find another udf under functions category with paremeter set > correctly This is normal; the above just inserts a record in the metadata tables; Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ? Michael. > > Codebue Fabio > .-----------------------------. > _ \ __| _|| > __/____|\__ \ _ \ _| _| > _| ____/\___/_| \__| > > P-Soft di Codebue Fabio & C. sas > via B.Storti, 19 > 24060 - Chiuduno - BG > Italy > Phone: +39.030.839435 > Fax: +39.030.5100306 > Mobile: +39.348.3515786 > .-----------------------------. > Web : www.p-soft.biz > EMail: > > -----Original Message----- > From: > On Behalf Of Michael Van > Canneyt > Sent: Thursday, March 13, 2008 9:52 AM > To: ; FPC-Pascal users discussions > Subject: Re: [fpc-pascal] Firebird UDF > > > > On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > > > This is my UDF source > > > > library pudf; > > {$mode objfpc}{$H+} > > uses > > Classes; > > > > function pround(var valore: real; ndec: integer):real;export; > > var > > i: integer; > > risultato: real; > > ndivisore: integer; > > begin > > risultato:= valore; > > ndivisore:= 1; > > for i:= 1 to ndec do > > begin > > risultato:= risultato*10; > > ndivisore:= ndivisore*10; > > end; > > result:= round(risultato)/ndivisore; > > end; > > > > exports > > pround name 'pround'; > > > > begin > > end. > > > > but after insert into my fdb with instruction > > > > DECLARE EXTERNAL FUNCTION pround > > DOUBLE PRECISION, INTEGER > > RETURNS DOUBLE PRECISION BY VALUE > > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > > > if I use it with an instruction like this > > > > select round(123.1233, 2) as nrounded from rdb$database > > > > I have back this error > > > > Invalid token. > > invalid request BLR at offset 59. > > function PROUND is not defined. > > module name or entrypoint could not be found. > > > > do you have some idea regarding this error? > > Where did you put the library, what is the library name ? > > Michael. > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Zaher Dirkey

Reply by email

zaher dirkey
to zaher dirkey

Hi Again,
try to copy ib_util.dll to system folder, or make PATH to Firebird bin folder.

and
(var valore: Double
not "real"

zaher dirkey wrote 176 lines
try to add "cdecl" | function pround(var valore: real; ndec: integer):real; cdecl; export; On Thu, Mar 13, 2008 at 11:43 AM, Codebue Fabio - P-Soft < > wrote: > I try with pudf.dll module name, I try to change function name ... I try > a > lot of things... > sigh a so stupid UDF, and I can't create it... > > mmm > > I'm using firebird 2.0.3 in windows vista environment. pudf was compiled > with fpc 2.0.4 and created with lazarus 0.9.22 > > sigh! > > > Codebue Fabio > .-----------------------------. > _ \ __| _|| > __/____|\__ \ _ \ _| _| > _| ____/\___/_| \__| > > P-Soft di Codebue Fabio & C. sas > via B.Storti, 19 > 24060 - Chiuduno - BG > Italy > Phone: +39.030.839435 > Fax: +39.030.5100306 > Mobile: +39.348.3515786 > .-----------------------------. > Web : www.p-soft.biz > EMail: > > -----Original Message----- > From: > On Behalf Of Michael > Van > Canneyt > Sent: Thursday, March 13, 2008 10:24 AM > To: FPC-Pascal users discussions > Subject: RE: [fpc-pascal] Firebird UDF > > > > On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > > > I create a pudf.dll library an put in UDF subdirectory of firebird > > installation (where you can find other UDFs) > > > > after this I use IBExpert to run the script > > > > DECLARE EXTERNAL FUNCTION pround > > DOUBLE PRECISION, INTEGER > > RETURNS DOUBLE PRECISION BY VALUE > > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > > > it run ok, I find another udf under functions category with paremeter > set > > correctly > > This is normal; the above just inserts a record in the metadata tables; > Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ? > > Michael. > > > > > Codebue Fabio > > .-----------------------------. > > _ \ __| _|| > > __/____|\__ \ _ \ _| _| > > _| ____/\___/_| \__| > > > > P-Soft di Codebue Fabio & C. sas > > via B.Storti, 19 > > 24060 - Chiuduno - BG > > Italy > > Phone: +39.030.839435 > > Fax: +39.030.5100306 > > Mobile: +39.348.3515786 > > .-----------------------------. > > Web : www.p-soft.biz > > EMail: > > > > -----Original Message----- > > From: > > On Behalf Of Michael > Van > > Canneyt > > Sent: Thursday, March 13, 2008 9:52 AM > > To: ; FPC-Pascal users discussions > > Subject: Re: [fpc-pascal] Firebird UDF > > > > > > > > On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote: > > > > > This is my UDF source > > > > > > library pudf; > > > {$mode objfpc}{$H+} > > > uses > > > Classes; > > > > > > function pround(var valore: real; ndec: integer):real;export; > > > var > > > i: integer; > > > risultato: real; > > > ndivisore: integer; > > > begin > > > risultato:= valore; > > > ndivisore:= 1; > > > for i:= 1 to ndec do > > > begin > > > risultato:= risultato*10; > > > ndivisore:= ndivisore*10; > > > end; > > > result:= round(risultato)/ndivisore; > > > end; > > > > > > exports > > > pround name 'pround'; > > > > > > begin > > > end. > > > > > > but after insert into my fdb with instruction > > > > > > DECLARE EXTERNAL FUNCTION pround > > > DOUBLE PRECISION, INTEGER > > > RETURNS DOUBLE PRECISION BY VALUE > > > ENTRY_POINT 'pround' MODULE_NAME 'pudf'; > > > > > > if I use it with an instruction like this > > > > > > select round(123.1233, 2) as nrounded from rdb$database > > > > > > I have back this error > > > > > > Invalid token. > > > invalid request BLR at offset 59. > > > function PROUND is not defined. > > > module name or entrypoint could not be found. > > > > > > do you have some idea regarding this error? > > > > Where did you put the library, what is the library name ? > > > > Michael. > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > -- Zaher Dirkey
Zaher Dirkey

Reply by email

Stephano
to Codebue Fabio - P-Soft: This is my UDF source library pudf; {$mode objfpc}{$H+} uses Classes; function pround(var…
Codebue Fabio - P-Soft wrote 48 lines
This is my UDF source library pudf; {$mode objfpc}{$H+} uses Classes; function pround(var valore: real; ndec: integer):real;export; var i: integer; risultato: real; ndivisore: integer; begin risultato:= valore; ndivisore:= 1; for i:= 1 to ndec do begin risultato:= risultato*10; ndivisore:= ndivisore*10; end; result:= round(risultato)/ndivisore; end; exports pround name 'pround'; begin end. but after insert into my fdb with instruction DECLARE EXTERNAL FUNCTION pround DOUBLE PRECISION, INTEGER RETURNS DOUBLE PRECISION BY VALUE ENTRY_POINT 'pround' MODULE_NAME 'pudf'; if I use it with an instruction like this select round(123.1233, 2) as nrounded from rdb$database I have back this error Invalid token. invalid request BLR at offset 59. function PROUND is not defined. module name or entrypoint could not be found. do you have some idea regarding this error?

1- You should use cdecl for your function

2- you should use pudf_pround as module entry name

3- use double instead of real

I hope this helps.

Reply by email

Codebue Fabio - P-Soft
to Stephano

nothing todo...
ok restart:
library pudf;

{$mode objfpc}{$H+}

uses
Classes,

  p_func in 'p_func.pas';
exports
  pround name 'p_round';
{$R pudf.res}
begin
//  DECLARE EXTERNAL FUNCTION pround
//   DOUBLE PRECISION, INTEGER
//   RETURNS DOUBLE PRECISION BY VALUE
//  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';
end.

and

unit p_func;
{$mode objfpc}{$H+}
interface
  function p_round(var valore: double; ndec: integer): double; cdecl;
implementation
uses
  Classes, SysUtils;
function p_round(var valore: double; ndec: integer): double; cdecl;
var
  i: integer;
  risultato: double;
  ndivisore: integer;
begin
  risultato:= valore;
  ndivisore:= 1;
  for i:= 1 to ndec do
  begin
    risultato:= risultato*10;
    ndivisore:= ndivisore*10;
  end;
  result:= round(risultato)/ndivisore;
end;
end.

someone can compile and install?

I can... but when I try to execute

select round(123.1233, 2) as nrounded from rdb$database

always some error!!!

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Reply by email

bartek
to Graeme Geldenhuys: Thanks Jeff. That seems to work fine with my project under Linux. Now I only need to…
Graeme Geldenhuys wrote 5 lines
Thanks Jeff. That seems to work fine with my project under Linux. Now I only need to learn the format and meaning of all the numbers in callgrind.log file. But I'm sure the website or man pages will give info on that.

kcachegrind is a excellent front-end for valgrind. Depending on your distro this should be in kde-devel.

Reply by email

Stephano
to Codebue Fabio - P-Soft: nothing todo... ok restart: library pudf; {$mode objfpc}{$H+} uses p_func in 'p_func.pas';
Codebue Fabio - P-Soft wrote 64 lines
nothing todo... ok restart: library pudf; {$mode objfpc}{$H+} uses Classes, p_func in 'p_func.pas'; exports pround name 'p_round'; {$R pudf.res} begin // DECLARE EXTERNAL FUNCTION pround // DOUBLE PRECISION, INTEGER // RETURNS DOUBLE PRECISION BY VALUE // ENTRY_POINT 'pudf_pround' MODULE_NAME 'pudf'; end. and unit p_func; {$mode objfpc}{$H+} interface function p_round(var valore: double; ndec: integer): double; cdecl; implementation uses Classes, SysUtils; function p_round(var valore: double; ndec: integer): double; cdecl; var i: integer; risultato: double; ndivisore: integer; begin risultato:= valore; ndivisore:= 1; for i:= 1 to ndec do begin risultato:= risultato*10; ndivisore:= ndivisore*10; end; result:= round(risultato)/ndivisore; end; end. someone can compile and install? I can... but when I try to execute select round(123.1233, 2) as nrounded from rdb$database always some error!!!

You are exporting now the function as p_round. So I guess your entry point should be pudf_p_round.

Furthermore, your sql includes round and not pround!

What is the error message you got?

Reply by email

Codebue Fabio - P-Soft
to Stephano

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Earlier message 79 lines
-----Original Message----- From: On Behalf Of Stephano Sent: Thursday, March 13, 2008 8:09 PM To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Firebird UDF Codebue Fabio - P-Soft wrote: > nothing todo... > ok restart: > library pudf; > > {$mode objfpc}{$H+} > > uses > Classes, > p_func in 'p_func.pas'; > > exports > pround name 'p_round'; > > {$R pudf.res} > > begin > > // DECLARE EXTERNAL FUNCTION pround > // DOUBLE PRECISION, INTEGER > // RETURNS DOUBLE PRECISION BY VALUE > // ENTRY_POINT 'pudf_pround' MODULE_NAME 'pudf'; > > end. > > and > > unit p_func; > > {$mode objfpc}{$H+} > > interface > function p_round(var valore: double; ndec: integer): double; cdecl; > > implementation > > uses > Classes, SysUtils; > > function p_round(var valore: double; ndec: integer): double; cdecl; > var > i: integer; > risultato: double; > ndivisore: integer; > begin > > risultato:= valore; > ndivisore:= 1; > for i:= 1 to ndec do > begin > risultato:= risultato*10; > ndivisore:= ndivisore*10; > end; > > result:= round(risultato)/ndivisore; > end; > end. > > someone can compile and install? > > I can... but when I try to execute > > select round(123.1233, 2) as nrounded from rdb$database > > always some error!!! You are exporting now the function as p_round. So I guess your entry point should be pudf_p_round. Furthermore, your sql includes round and not pround! What is the error message you got?

Reply by email

Codebue Fabio - P-Soft
to Stephano: You are exporting now the function as p_round. So I guess your entry point should be…

I register my udfp with command

DECLARE EXTERNAL FUNCTION pround
DOUBLE PRECISION, INTEGER
RETURNS DOUBLE PRECISION BY VALUE

  ENTRY_POINT 'pudf_p_round'  MODULE_NAME 'pudf';

and test with this sql

select round(123.1233, 2) as nrounded from rdb$database

returning error

Invalid token.
invalid request BLR at offset 59.
function PROUND is not defined.
module name or entrypoint could not be found.

I try to register with
ENTRY_POINT 'p_round' or
MODULE_NAME 'pudf.dll'

nothing todo!!!

I have to set particular linker or compiler parameters?

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Earlier message 79 lines
-----Original Message----- From: On Behalf Of Stephano Sent: Thursday, March 13, 2008 8:09 PM To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Firebird UDF Codebue Fabio - P-Soft wrote: > nothing todo... > ok restart: > library pudf; > > {$mode objfpc}{$H+} > > uses > Classes, > p_func in 'p_func.pas'; > > exports > pround name 'p_round'; > > {$R pudf.res} > > begin > > // DECLARE EXTERNAL FUNCTION pround > // DOUBLE PRECISION, INTEGER > // RETURNS DOUBLE PRECISION BY VALUE > // ENTRY_POINT 'pudf_pround' MODULE_NAME 'pudf'; > > end. > > and > > unit p_func; > > {$mode objfpc}{$H+} > > interface > function p_round(var valore: double; ndec: integer): double; cdecl; > > implementation > > uses > Classes, SysUtils; > > function p_round(var valore: double; ndec: integer): double; cdecl; > var > i: integer; > risultato: double; > ndivisore: integer; > begin > > risultato:= valore; > ndivisore:= 1; > for i:= 1 to ndec do > begin > risultato:= risultato*10; > ndivisore:= ndivisore*10; > end; > > result:= round(risultato)/ndivisore; > end; > end. > > someone can compile and install? > > I can... but when I try to execute > > select round(123.1233, 2) as nrounded from rdb$database > > always some error!!! You are exporting now the function as p_round. So I guess your entry point should be pudf_p_round. Furthermore, your sql includes round and not pround! What is the error message you got?

Reply by email

Codebue Fabio - P-Soft
to zaher dirkey: try to copy ib_util.dll to system folder, or make PATH to Firebird bin folder. and (var…

I learn about all your tips... but nothing todo. I try to summarize I'm using firebird 2.0.3 in windows vista environment. pudf was compiled with fpc 2.0.4 and created with lazarus 0.9.22

project file

     library pudf;
{$mode objfpc}{$H+}

uses
Classes,

  p_func in 'p_func.pas';
exports
  p_round name 'p_round';
{$R pudf.res}
begin
end.

function file

unit p_func;
{$mode objfpc}{$H+}
interface
  function p_round(var valore: double; ndec: integer): double; cdecl;
implementation
uses
  Classes, SysUtils;
function p_round(var valore: double; ndec: integer): double; cdecl;
var
  i: integer;
  risultato: double;
  ndivisore: integer;
begin
  risultato:= valore;
  ndivisore:= 1;
  for i:= 1 to ndec do
  begin
    risultato:= risultato*10;
    ndivisore:= ndivisore*10;
  end;
  Result:= round(risultato)/ndivisore;
end;
end.

Declare command:

test commnand

select P_ROUND(123.1233, 2) as nrounded from rdb$database

error

Invalid token.
invalid request BLR at offset 59.
function P_ROUND is not defined.
module name or entrypoint could not be found.

Codebue Fabio
.-----------------------------.
_ \ __| _||
__/____|\__ \ _ \ _| _|
_| ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web : www.p-soft.biz
EMail:

Reply by email

Stephano
to Codebue Fabio - P-Soft: I register my udfp with command DECLARE EXTERNAL FUNCTION pround DOUBLE PRECISION, INTEGER
Show quoted text 64 lines
> nothing todo... > ok restart: > library pudf; > > {$mode objfpc}{$H+} > > uses > Classes, > p_func in 'p_func.pas'; > > exports > pround name 'p_round'; > > {$R pudf.res} > > begin > > // DECLARE EXTERNAL FUNCTION pround > // DOUBLE PRECISION, INTEGER > // RETURNS DOUBLE PRECISION BY VALUE > // ENTRY_POINT 'pudf_pround' MODULE_NAME 'pudf'; > > end. > > and > > unit p_func; > > {$mode objfpc}{$H+} > > interface > function p_round(var valore: double; ndec: integer): double; cdecl; > > implementation > > uses > Classes, SysUtils; > > function p_round(var valore: double; ndec: integer): double; cdecl; > var > i: integer; > risultato: double; > ndivisore: integer; > begin > > risultato:= valore; > ndivisore:= 1; > for i:= 1 to ndec do > begin > risultato:= risultato*10; > ndivisore:= ndivisore*10; > end; > > result:= round(risultato)/ndivisore; > end; > end. > > someone can compile and install? > > I can... but when I try to execute > > select round(123.1233, 2) as nrounded from rdb$database > > always some error!!!

- Entry point should be p_round only in this case

- Adding also 'export' in the function declaration should help:

function p_round(var valore: double; ndec: integer): double; cdecl; export;

- The following needs to be corrected as well:
exports p_round name 'p_round';
_________^

Reply by email

zaher dirkey
to Stephano

May be you UDF depend on external library try to View Dependency.

Stephano wrote 79 lines
>> nothing todo... >> ok restart: >> library pudf; >> >> {$mode objfpc}{$H+} >> >> uses >> Classes, >> p_func in 'p_func.pas'; >> >> exports >> pround name 'p_round'; >> >> {$R pudf.res} >> >> begin >> >> // DECLARE EXTERNAL FUNCTION pround >> // DOUBLE PRECISION, INTEGER >> // RETURNS DOUBLE PRECISION BY VALUE >> // ENTRY_POINT 'pudf_pround' MODULE_NAME 'pudf'; >> >> end. >> >> and >> >> unit p_func; >> >> {$mode objfpc}{$H+} >> >> interface >> function p_round(var valore: double; ndec: integer): double; cdecl; >> >> implementation >> >> uses >> Classes, SysUtils; >> >> function p_round(var valore: double; ndec: integer): double; cdecl; >> var >> i: integer; >> risultato: double; >> ndivisore: integer; >> begin >> >> risultato:= valore; >> ndivisore:= 1; >> for i:= 1 to ndec do >> begin >> risultato:= risultato*10; >> ndivisore:= ndivisore*10; >> end; >> >> result:= round(risultato)/ndivisore; >> end; >> end. >> >> someone can compile and install? >> >> I can... but when I try to execute >> >> select round(123.1233, 2) as nrounded from rdb$database >> >> always some error!!! - Entry point should be p_round only in this case - Adding also 'export' in the function declaration should help: function p_round(var valore: double; ndec: integer): double; cdecl; export; - The following needs to be corrected as well: exports p_round name 'p_round'; _________^ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Zaher Dirkey

Reply by email