Re[4]: [fpc-pascal] UDF+FREEBSD+FIREBIRD

2008-11-15 Thread Michael Van Canneyt


On Sat, 15 Nov 2008, KES wrote:

> Здравствуйте, Michael.
> 
> Вы писали 15 ноября 2008 г., 2:52:48:
> 
> 
> 
> MVC> On Sat, 15 Nov 2008, KES wrote:
> 
> >> Здравствуйте, Michael.
> 
> MVC> Zdravstvuyte...
> 
> >> >> I have tryied my example to compile in Delphi. Then I use DLL in
> >> >> FireBird on Win32. All works fine. So my source file is good
> >> >> and therefore FreePascal can not compile shared library that can be
> >> >> recognized by FireBird (((
> >> 
> >> MVC> Did you specify cdecl as the calling convention for non-windows ?
> >> MVC> If it works on windows, it almost surely does not work straight out
> >> MVC> of the box on unices, because the calling convention will be wrong.
> >> 
> >> MVC> Michael.
> >> 
> >> This is last my try:
> >> 
> >> library MyUDF;
> >> 
> >> 
> >> function somefn: integer; cdecl; export;
> >> begin
> >>  somefn:= 3;
> >> end;
> >> 
> >> exports
> >>  somefn name '_somefn';
> >> end.
> >> 
> >> On win32 it works, on FreeBSD does not
> 
> MVC> I compiled the library, and checked the contents:
> 
> home: >>objdump -t libmyudf.so  
> 
> MVC> 4a20 g F .text  0005 _somefn
> 
> MVC> So the symbol is present, as you declared it in your library. 
> MVC> That part seems OK.
> 
> MVC> How do you declare your function in Firebird ?
> MVC> Does it have the _ ? 
> MVC> and the correct casing ?
> 
> MVC> Michael.
> 
> I have tryied with and without _
> 
> DECLARE EXTERNAL FUNCTION FNTEST
>   RETURNS INTEGER
>   ENTRY_POINT 'somefn'
>   MODULE_NAME 'myudf'
> 
> 
> DECLARE EXTERNAL FUNCTION FNTEST
>   RETURNS INTEGER
>   ENTRY_POINT '_somefn'
>   MODULE_NAME 'myudf'

Did you try changing the name myudf to libmyudf.so or libmyudf ?
I don't think that the 'lib' is prefixed automatically.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Make FPC closer to hardware

2008-11-15 Thread Micha Nelissen

leledumbo wrote:

Would it be a good idea to lower down (again) FPC so that it can be used
easier for systems programming?


example?

Micha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[2]: [fpc-pascal] UDF+FREEBSD+FIREBIRD

2008-11-15 Thread KES
Здравствуйте, Stephano.

Вы писали 15 ноября 2008 г., 9:52:09:

S> KES wrote:
>> library tkes2;
>> 
>> {$mode objfpc}
>> {$PACKRECORDS C}
>> 
>> 
>> function somefn: integer; cdecl; export;
>> begin
>>  somefn:= 3;
>> end;
>> 
>> exports
>>  //I do not do as:
>>  // somefn name 'somefn'; // because of this cause error tkes2(17,1) Error: 
>> Asm: Duplicate label somefn
>> 
>>  //so I do as:
>>  somefn name '_somefn';
>> 
>> end.
>> 
>> #fpc tkes2 -Xp
>> Free Pascal Compiler version 2.2.0 [2008/11/09] for i386
>> Copyright (c) 1993-2007 by Florian Klaempfl
>> Target OS: FreeBSD/ELF for i386
>> Compiling tkes2
>> Linking libtkes2.so
>> 17 lines compiled, 0.1 sec
>> 
>> #ld -shared -soname libtkes2.so.1 -o libtkes2.so.1.0 -lc tkes2.o
>> #cp tkes2.so /usr/local/libexec/firebird/udf/
>> #cp tkes2.so.1.0 /usr/local/libexec/firebird/udf/
>> #cd /usr/local/libexec/firebird/udf/
>> #ls -l
>> -rwxr-xr-x  1 root  wheel  6022 12 РЅРѕСЏ 04:07 libtkes2.so
>> -rwxr-xr-x  1 root  wheel  3219 12 РЅРѕСЏ 04:32 libtkes2.so.1.0
>> 
>> # /etc/rc.d/inetd restart
>> Stopping inetd.
>> Starting inetd.
>> 
>> in SQL:
>> DECLARE EXTERNAL FUNCTION FNTEST2
>>   RETURNS INTEGER BY VALUE 
>>   ENTRY_POINT 'tkes2__somefn'
>>   MODULE_NAME 'libtkes2'
>> 
>> select fntest2() from sometable;
>> 
>> invalid requiest BLR at offset 64
>> function FNTEST2 is not defined
>> module name or entrypoint could not be found
>> 
>> repeat:
>> DECLARE EXTERNAL FUNCTION FNTEST2
>>   RETURNS INTEGER BY VALUE 
>>   ENTRY_POINT 'tkes2_somefn'
>>   MODULE_NAME 'libtkes2'
>> 
>> select fntest2() from sometable;
>> 
>> invalid requiest BLR at offset 64
>> function FNTEST2 is not defined
>> module name or entrypoint could not be found
>> 
>> another try:
>> 
>> DECLARE EXTERNAL FUNCTION FNTEST2
>>   RETURNS INTEGER BY VALUE 
>>   ENTRY_POINT '_somefn'
>>   MODULE_NAME 'libtkes2'
>> 
>> select fntest2() from sometable;
>> 
>> invalid requiest BLR at offset 64
>> function FNTEST2 is not defined
>> module name or entrypoint could not be found
>> 
>> 
>> DECLARE EXTERNAL FUNCTION FNTEST2
>>   RETURNS INTEGER BY VALUE 
>>   ENTRY_POINT 'somefn'
>>   MODULE_NAME 'libtkes2'
>> 
>> select fntest2() from sometable;
>> 
>> invalid requiest BLR at offset 64
>> function FNTEST2 is not defined
>> module name or entrypoint could not be found
>> 
>> 
>> 
>> What is wrong?
>> 

S> The Firebird message gives two possible causes:
S> module name OR entry point not found

S> In your case, it could be that it is the module itself which cannot be
S> located. I noticed you copy tkes2 to the udf folder while you tell 
S> firebird the module name is libtkes2.

I have tryied both libtkes2 and tkes2 as Marc Santhoff adviced on 13 November

S> NB: This does not explain the ls -l which shows libtkes2 entries, unless
S> these are old entries

This I have wrote 12 November:

>DECLARE EXTERNAL FUNCTION FNTEST2
>  RETURNS INTEGER BY VALUE
>  ENTRY_POINT '_somefn'
>  MODULE_NAME 'libtkes2'
>
>select fntest2() from sometable;
>
>invalid requiest BLR at offset 64
>function FNTEST2 is not defined
>module name or entrypoint could not be found
>
>
>DECLARE EXTERNAL FUNCTION FNTEST2
>  RETURNS INTEGER BY VALUE
>  ENTRY_POINT 'somefn'
>  MODULE_NAME 'libtkes2'

-- 
С уважением,
 KES  mailto:[EMAIL PROTECTED]

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] UDF+FREEBSD+FIREBIRD

2008-11-15 Thread Stephano

KES wrote:

#ld -shared -soname libtkes2.so.1 -o libtkes2.so.1.0 -lc tkes2.o
#cp tkes2.so /usr/local/libexec/firebird/udf/
#cp tkes2.so.1.0 /usr/local/libexec/firebird/udf/
#cd /usr/local/libexec/firebird/udf/
#ls -l


Is the above used in a script? If yes, then it is linking into 
libtkes2.so, but copying to the udf directory tkes2.so (which might not 
even exist).

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[5]: [fpc-pascal] UDF+FREEBSD+FIREBIRD

2008-11-15 Thread KES
Здравствуйте, Michael.

Вы писали 15 ноября 2008 г., 12:23:55:



MVC> On Sat, 15 Nov 2008, KES wrote:

>> Здравствуйте, Michael.
>> 
>> Вы писали 15 ноября 2008 г., 2:52:48:
>> 
>> 
>> 
>> MVC> On Sat, 15 Nov 2008, KES wrote:
>> 
>> >> Здравствуйте, Michael.
>> 
>> MVC> Zdravstvuyte...
>> 
>> >> >> I have tryied my example to compile in Delphi. Then I use DLL in
>> >> >> FireBird on Win32. All works fine. So my source file is good
>> >> >> and therefore FreePascal can not compile shared library that can be
>> >> >> recognized by FireBird (((
>> >> 
>> >> MVC> Did you specify cdecl as the calling convention for non-windows ?
>> >> MVC> If it works on windows, it almost surely does not work straight out
>> >> MVC> of the box on unices, because the calling convention will be wrong.
>> >> 
>> >> MVC> Michael.
>> >> 
>> >> This is last my try:
>> >> 
>> >> library MyUDF;
>> >> 
>> >> 
>> >> function somefn: integer; cdecl; export;
>> >> begin
>> >>  somefn:= 3;
>> >> end;
>> >> 
>> >> exports
>> >>  somefn name '_somefn';
>> >> end.
>> >> 
>> >> On win32 it works, on FreeBSD does not
>> 
>> MVC> I compiled the library, and checked the contents:
>> 
>> home: >>objdump -t libmyudf.so  
>> 
>> MVC> 4a20 g F .text  0005 _somefn
>> 
>> MVC> So the symbol is present, as you declared it in your library. 
>> MVC> That part seems OK.
>> 
>> MVC> How do you declare your function in Firebird ?
>> MVC> Does it have the _ ? 
>> MVC> and the correct casing ?
>> 
>> MVC> Michael.
>> 
>> I have tryied with and without _
>> 
>> DECLARE EXTERNAL FUNCTION FNTEST
>>   RETURNS INTEGER
>>   ENTRY_POINT 'somefn'
>>   MODULE_NAME 'myudf'
>> 
>> 
>> DECLARE EXTERNAL FUNCTION FNTEST
>>   RETURNS INTEGER
>>   ENTRY_POINT '_somefn'
>>   MODULE_NAME 'myudf'

MVC> Did you try changing the name myudf to libmyudf.so or libmyudf ?
MVC> I don't think that the 'lib' is prefixed automatically.

MVC> Michael.

Yes I did, Marc Santhoff advice me this on 13 Novemter

-- 
С уважением,
 KES  mailto:[EMAIL PROTECTED]

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] TBufDataset broken in fixes_2_2

2008-11-15 Thread Funky Beast
Hi,

TBufDataset is broken in latest fixes_2_2.

Can be reproduce with following code:

var s: TSQLQuery;
begin
 s := TSQLQuery;
 s.Free;
end;

Compiling fcl-db with debug info, the above code excepts
at TBufDataset.Destroy destructor at the following position:

For I:=0 to Length(FIndexes)-1 do
FreeAndNil(Findexes[I]);

It stops at the FreeAndNil line.

Latest trunk 2.3.1 has no such problem.

Should I file a bug report?

Regards,
Funky Beast
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TBufDataset broken in fixes_2_2

2008-11-15 Thread Jonas Maebe


On 15 Nov 2008, at 16:56, Funky Beast wrote:


Should I file a bug report?


Yes, please.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: TBufDataset broken in fixes_2_2

2008-11-15 Thread Funky Beast
Jonas Maebe wrote:
> 
> On 15 Nov 2008, at 16:56, Funky Beast wrote:
> 
>> Should I file a bug report?
> 
> Yes, please.
> 
> 
> Jonas
> ___
> fpc-pascal maillist  - 
> [EMAIL PROTECTED]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 

Done in bug ID: 0012639

Regards,
Funky Beast
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[5]: [fpc-pascal] UDF+FREEBSD+FIREBIRD

2008-11-15 Thread KES
Здравствуйте

Lets try all from beginning

1. Test how firebird recognize libxxx and xxx and xxx.so libraries
(because of C variant of UDF works I will try gcc)

a) source file:
extern int c_test();

int c_test()
{
return 8;
}


-- 
С уважением,
 KES  mailto:[EMAIL PROTECTED]

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Starting out with Free Pascal

2008-11-15 Thread Bill

Hello,

I'm absolutely new to this list... and to Pascal. I was getting pretty 
good with Foxpro programming when MS bought and then changed the 
program, eventually to kill it.  I see the need to get back into 
programming and I remember a Foxpro instructor saying that Pascal was 
similar. So here are my initial questions:
Should I learn study FPC first and then move on to Lazarus, or just 
start with Lazarus?

What books would you suggest?
My interest is still in databases. Anything else I should know about 
pointing myself in that direction?


Thanks.
Bill
Minden, NV
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[5]: [fpc-pascal] UDF+FREEBSD+FIREBIRD FPC generate wrong object file???

2008-11-15 Thread Michael Van Canneyt


On Sat, 15 Nov 2008, KES wrote:

> Здравствуйте
> 
> h) select fntest() from rdb$database
> i) invalid requiest BLR at offset 60
> function FNTEST is not defined
> module name or entrypoint could not be found
> 
> 
> CONCLUSION: FPC generate wrong object file???

Not necessarily. Please try to load the library from a plain C program.

My guess is that dlopen() will return an error.

Then do the same for the library with a pascal program.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re[6]: [fpc-pascal] UDF+FREEBSD+FIREBIRD FPC generate wrong object file???

2008-11-15 Thread KES
Здравствуйте, Michael.

Вы писали 15 ноября 2008 г., 23:28:10:



MVC> On Sat, 15 Nov 2008, KES wrote:

>> Здравствуйте
>> 
>> h) select fntest() from rdb$database
>> i) invalid requiest BLR at offset 60
>> function FNTEST is not defined
>> module name or entrypoint could not be found
>> 
>> 
>> CONCLUSION: FPC generate wrong object file???

MVC> Not necessarily. Please try to load the library from a plain C program.

MVC> My guess is that dlopen() will return an error.

MVC> Then do the same for the library with a pascal program.

MVC> Michael.

I do not know how to load the library from a plain C program. Can you
help me?

-- 
С уважением,
 KES  mailto:[EMAIL PROTECTED]

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re[6]: [fpc-pascal] UDF+FREEBSD+FIREBIRD FPC generate wrong object file???

2008-11-15 Thread Michael Van Canneyt


On Sat, 15 Nov 2008, KES wrote:

> Здравствуйте, Michael.
> 
> Вы писали 15 ноября 2008 г., 23:28:10:
> 
> 
> 
> MVC> On Sat, 15 Nov 2008, KES wrote:
> 
> >> Здравствуйте
> >> 
> >> h) select fntest() from rdb$database
> >> i) invalid requiest BLR at offset 60
> >> function FNTEST is not defined
> >> module name or entrypoint could not be found
> >> 
> >> 
> >> CONCLUSION: FPC generate wrong object file???
> 
> MVC> Not necessarily. Please try to load the library from a plain C program.
> 
> MVC> My guess is that dlopen() will return an error.
> 
> MVC> Then do the same for the library with a pascal program.
> 
> MVC> Michael.
> 
> I do not know how to load the library from a plain C program. Can you
> help me?

Something like this should do it:

home: >cat testl.c
#include 
#include 
int main () {
  void * p;
  void * ps;
  p=dlopen("testudf.so",RTLD_NOW);
  if (p==NULL) {
printf("loading library failed %s\n",dlerror());
  } else {
printf("loading library OK\n");
ps = dlsym(p,"fn_test");
if (ps==NULL) {
  printf("symbol not found\n");
} else {
  printf("Symbol found OK\n");
}
   dlclose(p);
  }
}

home: >gcc -ldl testl.c
home: >./a.out
loading library failed testudf.so: cannot open shared object file: No such file 
or directory

Of course,  you must correct the names.

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: Re[6]: [fpc-pascal] UDF+FREEBSD+FIREBIRD FPC generate wrong object file???

2008-11-15 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said:
> home: >gcc -ldl testl.c
> home: >./a.out
> loading library failed testudf.so: cannot open shared object file: No such 
> file or directory

(skip the -ldl, it is a linuxism)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] re-opening stdout and sdterr

2008-11-15 Thread Marc Santhoff
Am Donnerstag, den 13.11.2008, 20:57 +0100 schrieb Jonas Maebe:
> On 13 Nov 2008, at 01:42, Marc Santhoff wrote:
> 
> > long time ago I had problems with stdxxx being in non-blocking i/o  
> > mode.
> > The suggestion was to close and re-open the channels from the system
> > units init code.
> >
> > I ran into this problem again and would like to know:
> >
> > How can I close and reopen stderr and sdtout from my program?
> 
> close(stderr);
> assign(stderr,'');
> rewrite(stderr);
> 
> close(stdout);
> assign(stdout,'');
> rewrite(stdout);
> 
> This does not enable you to set any particular options on the  
> descriptors though, 

As expected it does work but doesn't change blocking behaviour.

> and I'm not aware of any supported way for doing  
> so (read: a way which is likely to be forward compatible).

Don't get you here, what do you mean by forward compatible?

>  And even if  
> you could get at the file descriptors, there is also no cross-platform  
> functionality that I'm aware of to change their (non-)blocking setting.

No, not cross platform, but I was able to make a solution for FreeBSD 4,
I assume it'll work (with minor modifications) on other unix-like
platforms:

uses unix;

var
  res: longint; // or cint

begin

  res := fpfcntl(TextRec(stderr).Handle, F_GETFL);
  if ((O_NONBLOCK AND res)>0) then
  begin
res := res AND (NOT O_NONBLOCK);
res := fpfcntl(TextRec(stderr).Handle, F_SETFL, res);
if (res=-1) then writeln(stderr, 'ERROR on SETFL');
  end;

This switches the channel to blocking mode and the overrun errors
disappear in this case.

Thanks for your help,
Marc


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Starting out with Free Pascal

2008-11-15 Thread Graeme Geldenhuys
On Sat, Nov 15, 2008 at 10:17 PM, Bill <[EMAIL PROTECTED]> wrote:
> Should I learn study FPC first and then move on to Lazarus, or just start
> with Lazarus?

I think it should be okay to start directly with Lazarus. Lazarus IDE
makes project management much easier and has some fantastic editor
features.

> What books would you suggest?

I don't know about books, but any Delphi book should do. Free Pascal
and Lazarus is very close to Delphi.
Also to a few Google searches on the topic. Again, whatever you find
for Delphi should apply directly or at least very close to Lazarus.
If you get stuck, you can always post your questions here or in the
Lazarus mailing list.

http://www.delphibasics.co.uk/
http://www.bitwisemag.com/2/Learn-To-Program-Delphi-Part-One
http://www.delphifusion.com/delphi/a-guide-to-learning-delphi.html

Some books:

* Learning to Program in Pascal and Delphi, ISBN: 978-1904467298
* Delphi in a Nutshell: A Desktop Quick Reference, ISBN: 978-1565926592
* Tomes Of Delphi: Basic 32-Bit Communications Programming, ISBN:
978-1556227523
* Mastering Borland Delphi 2005, ISBN: 978-0782143423


Regards,
  - Graeme -


___
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal