[fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
Hello. I have a external dll. In Windows i can access perfectly the procedures with GetProcAddress() if i use Windows unit. If i use DynLibs unit, prog crash when i try to load the procedure. I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so). I have try, in linux to access the procedure with DynLibs too but same crash than for Windows. What must i do to access procedure with DynLibs ? Many thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: Hello. I have a external dll. In Windows i can access perfectly the procedures with GetProcAddress() if i use Windows unit. If i use DynLibs unit, prog crash when i try to load the procedure. I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so). I have try, in linux to access the procedure with DynLibs too but same crash than for Windows. What must i do to access procedure with DynLibs ? Can you be more specific ? What error do you get ? Can show some code ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, January 13, 2014 11:47, Fred van Stappen wrote: Hello. I have a external dll. In Windows i can access perfectly the procedures with GetProcAddress() if i use Windows unit. If i use DynLibs unit, prog crash when i try to load the procedure. I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so). I have try, in linux to access the procedure with DynLibs too but same crash than for Windows. What must i do to access procedure with DynLibs ? Can you provide a simplified program demonstrating the problem? Does it crash when trying the obtain the address, or when trying to use it (e.g. after assignment to a procedural variable)? If it is the latter, have you checked that the calling conventions of your DLL and your procedural type match? If it is the former, how is the crash demonstrated (i.e. what happens)? Tomas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
Date: Mon, 13 Jan 2014 11:58:21 +0100 From: mich...@freepascal.org To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() On Mon, 13 Jan 2014, Fred van Stappen wrote: Hello. I have a external dll. In Windows i can access perfectly the procedures with GetProcAddress() if i use Windows unit. If i use DynLibs unit, prog crash when i try to load the procedure. I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so). I have try, in linux to access the procedure with DynLibs too but same crash than for Windows. What must i do to access procedure with DynLibs ? Can you be more specific ? What error do you get ? Can show some code ? Michael. Hello and many thanks for answer. The library is SoundTouch.dll and libSoundTouch.so from : http://www.surina.net/soundtouch/ Here part of working code (if i call soundtouch_createInstance, it works) ... uses Windows ; ... var soundtouch_createInstance : function() : THandle; stdcall; ... procedure InitLib(LibFile : PAnsiChar); begin LibHandle := LoadLibrary(LibFile); if LibHandle 0 then Pointer(soundtouch_createInstance) := GetProcAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); / Here part of NOT working code (if i call soundtouch_createInstance, it crash) ... uses dynlibs ; ... var soundtouch_createInstance : function() : THandle; stdcall; ... procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); / Many thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: Here part of NOT working code (if i call soundtouch_createInstance, it crash) ... uses dynlibs ; ... var soundtouch_createInstance : function() : THandle; stdcall; ... procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance) := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); Remove the typecast PansiChar() Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault
I had a look at armv6m yesterday evening, parts of my code run fine in gdb, the code crashes in the init of a procedure when trying to prepare the access to contents of a set. The address of the set seems to get calculated totally wrong ending up in a memory access at the end of the chip's address range. Not sure if this is related to your problem, I will try to boil down the example to a bare minimum to see where the generated code differs between armv7m and armv6m. Michael Am 11.01.14 14:17, schrieb Reinier Olislagers: On 11/01/2014 14:03, Florian Klämpfl wrote: Just type fpc -i to see the possible options. If one does not understand those options, one does not need them :) I had a suspicion you were going to say that ;) As said, arm targets are very different and every target has its optimal parameters. Exactly. Having some additional info IMO helps to at least verify the choice somebody else made in his script/wiki page/build tool is correct ;) E.g. on my NAS running debian 6.0 I build for thumb with CROSSOPT=-O4 -Cparmv5te -CIthumb and for normal arm with CROSSOPT=-O4 -Cparmv5te Depending on the distro, one needs different -Fl switches etc. Not to talk about different OSes. Yep. -Fl is covered in the cross compiling article, of course also in the build faq. Yes. But in my opinion then this info should go to the raspi page. I bet 99% of the raspi users don't know what instruction set the raspi needs. So explaining that -Cparmv6 turns on armv6 code generation does not help them :) Ehm, this is exactly why I didn't put it on the raspi page ;)... but a link from there to the current page would be nice... So when /is/ specifying the ABI needed? When supporting a microcontroller? Seriously: if you want to use an armel compiler to build e.g. for armhf. Ok. But then you probably want to have also some other defines and you really have to know what you are doing. Or if you have a special armel setup where you want to use hard float code and abi for speed reasons, e.g. when having softfloat raspberry debian installed. But these are special setups, officially not supported. Got it. Not interested in going that deep ;) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
Date: Mon, 13 Jan 2014 12:07:54 +0100 From: xhaj...@hajny.biz To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() On Mon, January 13, 2014 11:47, Fred van Stappen wrote: Hello. I have a external dll. In Windows i can access perfectly the procedures with GetProcAddress() if i use Windows unit. If i use DynLibs unit, prog crash when i try to load the procedure. I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so). I have try, in linux to access the procedure with DynLibs too but same crash than for Windows. What must i do to access procedure with DynLibs ? Can you provide a simplified program demonstrating the problem? Does it crash when trying the obtain the address, or when trying to use it (e.g. after assignment to a procedural variable)? If it is the latter, have you checked that the calling conventions of your DLL and your procedural type match? If it is the former, how is the crash demonstrated (i.e. what happens)? Tomas Hello Tomas. I have sent part of code in earlier topic, do you need more ? The crash append when i try to call the procedure. LoadLibrary(libfile) seems to work, i get result as true. Thanks ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
Tomas Hajny wrote: On Mon, January 13, 2014 11:47, Fred van Stappen wrote: Hello. I have a external dll. In Windows i can access perfectly the procedures with GetProcAddress() if i use Windows unit. If i use DynLibs unit, prog crash when i try to load the procedure. I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so). I have try, in linux to access the procedure with DynLibs too but same crash than for Windows. What must i do to access procedure with DynLibs ? Can you provide a simplified program demonstrating the problem? Does it crash when trying the obtain the address, or when trying to use it (e.g. after assignment to a procedural variable)? If it is the latter, have you checked that the calling conventions of your DLL and your procedural type match? If it is the former, how is the crash demonstrated (i.e. what happens)? Also note the availability of GetLoadErrorStr on most platforms in later versions of the RTL (= 2.6.2 I think). -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
Date: Mon, 13 Jan 2014 12:32:53 +0100 From: mich...@freepascal.org To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() On Mon, 13 Jan 2014, Fred van Stappen wrote: Here part of NOT working code (if i call soundtouch_createInstance, it crash) ... uses dynlibs ; ... var soundtouch_createInstance : function() : THandle; stdcall; ... procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Does TBufDataSet support Blob or memo field?
I created a TMemoField in TBufDataSet but no matter I do: 1) Field.asString := 'some value' or 2) Field.LoadFromStream(someStream). Afterwards, this F.AsString always returns '' and F.LoadFromStream(someStream) always has a 0 BlobSize afterwards. Anyone has similar experience? Dennis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: Date: Mon, 13 Jan 2014 12:32:53 +0100 From: mich...@freepascal.org To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() On Mon, 13 Jan 2014, Fred van Stappen wrote: Here part of NOT working code (if i call soundtouch_createInstance, it crash) ... uses dynlibs ; ... var soundtouch_createInstance : function() : THandle; stdcall; ... procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance) := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: Date: Mon, 13 Jan 2014 12:32:53 +0100 From: mich...@freepascal.org To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() On Mon, 13 Jan 2014, Fred van Stappen wrote: Here part of NOT working code (if i call soundtouch_createInstance, it crash) ... uses dynlibs ; ... var soundtouch_createInstance : function() : THandle; stdcall; ... procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Maybe, i dont understood your question... ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault
On 13/01/2014 12:34, Michael Ring wrote: I had a look at armv6m yesterday evening, parts of my code run fine in gdb, the code crashes in the init of a procedure when trying to prepare the access to contents of a set. The address of the set seems to get calculated totally wrong ending up in a memory access at the end of the chip's address range. Not sure if this is related to your problem, I will try to boil down the example to a bare minimum to see where the generated code differs between armv7m and armv6m. Thanks a lot, Michael! ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance) := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance ')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Do a Writeln((@soundtouch_createInstance)=Nil); Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance ')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Do a Writeln((@soundtouch_createInstance)=Nil); Michael. ___ Thanks Michael. Result in Linux for : if ST_Load('/home/fred/libSoundTouch/libSoundTouch.so') then writeln('ok') else writeln('no') ; ok Writeln((@soundtouch_createInstance)=Nil); FALSE I agree it is very strange, in windows, with unit Windows, it works perfectly.. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: On Mon, 13 Jan 2014, Fred van Stappen wrote: begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance) := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstan ce ')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Do a Writeln((@soundtouch_createInstance)=Nil); Michael. ___ Thanks Michael. Result in Linux for : if ST_Load('/home/fred/libSoundTouch/libSoundTouch.so') then writeln('ok') else writeln('no') ; ok Writeln((@soundtouch_createInstance)=Nil); FALSE I agree it is very strange, in windows, with unit Windows, it works perfectly.. Wait. What happens if you use dynlibs on windows ? Because there can be 1000 other reasons why the load failed on linux, not necessarily connected to dynlibs. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
Hi, 'scue me if I did not catch something, but On 13/01/14 12:13, Fred van Stappen wrote: [...] procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); /// why not just : @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); (or without the PAnsiChar cast as Michael said:) @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 'soundtouch_createInstance'); ? Remove the typecast PansiChar() Michael. [...] What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Maybe, i dont understood your question... if Assigned(soundtouch_createInstance) then ShowMessage('Got good pointer for soundtouch_createInstance') else ShowMessage('soundtouch_createInstance not assigned); placed directly after the GetProcedureAddress call ? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On Mon, 13 Jan 2014, Fred van Stappen wrote: On Mon, 13 Jan 2014, Fred van Stappen wrote: begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstan ce ')); Remove the typecast PansiChar() Michael. Hello Michael and thanks for answer. But if i remove PansiChar(), i still get : An unhandled exception occurred at $: EAccessViolation: Access violation $ What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Do a Writeln((@soundtouch_createInstance)=Nil); Michael. ___ Thanks Michael. Result in Linux for : if ST_Load('/home/fred/libSoundTouch/libSoundTouch.so') then writeln('ok') else writeln('no') ; ok Writeln((@soundtouch_createInstance)=Nil); FALSE I agree it is very strange, in windows, with unit Windows, it works perfectly.. Wait. What happens if you use dynlibs on windows ? Because there can be 1000 other reasons why the load failed on linux, not necessarily connected to dynlibs. Michael. Yep, Michael, many thanks for helping. What happens if you use dynlibs on windows ? Exactly the same as for Linux, it crash. What i do not understand it is why, with Windows unit, it works perfectly and with Dynlibs unit, it crash. (with same code, of course). ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
To: fpc-pascal@lists.freepascal.org From: el.es...@gmail.com Date: Mon, 13 Jan 2014 12:52:51 + Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() Hi, 'scue me if I did not catch something, but On 13/01/14 12:13, Fred van Stappen wrote: [...] procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); /// why not just : @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); (or without the PAnsiChar cast as Michael said:) @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 'soundtouch_createInstance'); ? Remove the typecast PansiChar() Michael. [...] What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Maybe, i dont understood your question... if Assigned(soundtouch_createInstance) then ShowMessage('Got good pointer for soundtouch_createInstance') else ShowMessage('soundtouch_createInstance not assigned); placed directly after the GetProcedureAddress call ? ___ /// why not just : @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); (or without the PAnsiChar cast as Michael said:) @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 'soundtouch_createInstance'); Many thanks... but im in a web-cafe and they want to close, i have to go... I will try this and give you news later. Many thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
To: fpc-pascal@lists.freepascal.org From: el.es...@gmail.com Date: Mon, 13 Jan 2014 12:52:51 + Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() Hi, 'scue me if I did not catch something, but On 13/01/14 12:13, Fred van Stappen wrote: [...] procedure InitLib(LibFile : PAnsiChar); begin LibHandle:=DynLibs.LoadLibrary(libfilename); if LibHandle DynLibs.NilHandle then Pointer(soundtouch_createInstance):= DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); /// why not just : @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); (or without the PAnsiChar cast as Michael said:) @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, 'soundtouch_createInstance'); ? Remove the typecast PansiChar() Michael. [...] What is the value of Pointer(soundtouch_createInstance) after the above statement ? Is it nil ? Michael. Thanks for answer Michael. Hum, how can i get the value of pointer if the application crash when i do : FHandle := soundtouch_createInstance(); Maybe, i dont understood your question... if Assigned(soundtouch_createInstance) then ShowMessage('Got good pointer for soundtouch_createInstance') else ShowMessage('soundtouch_createInstance not assigned); placed directly after the GetProcedureAddress call ? ___ Hello Lucaz /// why not just : @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); Get that error : libSoundTouch.pas(56,5) Error: Can't assign values to an address ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault
Might be related to the mla/mls optimization which somehow has been enabled even though it's still broken - Reply message - Fra: Reinier Olislagers reinierolislag...@gmail.com Dato: man., jan. 13, 2014 13:44 Emne: [fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault Til: fpc-pascal@lists.freepascal.org On 13/01/2014 12:34, Michael Ring wrote: I had a look at armv6m yesterday evening, parts of my code run fine in gdb, the code crashes in the init of a procedure when trying to prepare the access to contents of a set. The address of the set seems to get calculated totally wrong ending up in a memory access at the end of the chip's address range. Not sure if this is related to your problem, I will try to boil down the example to a bare minimum to see where the generated code differs between armv7m and armv6m. Thanks a lot, Michael! ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault
I guess not, when I remember correctly this has already been repaired for armv6m. The problem for me is that .Lj9 is defined as a negative number. As a consequence r13 points to nirvana and str r0,[r13, #8] creates an Exception. # [87] begin push{r4,r14} ldr r4,.Lj9 add r13,r13,r4 # Var bit located at r13+0 # Var direction located at r13+4 # Var $self located at r13+8 str r0,[r13, #8] strbr1,[r13] str r2,[r13, #4] .Ll2: . .Lj9: .long -32840 .Lj7: .long 32768 .Lj10: .long 32840 .Lt2: Am 13.01.14 15:15, schrieb Jeppe Græsdal Johansen: Might be related to the mla/mls optimization which somehow has been enabled even though it's still broken - Reply message - Fra: Reinier Olislagers reinierolislag...@gmail.com Dato: man., jan. 13, 2014 13:44 Emne: [fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault Til: fpc-pascal@lists.freepascal.org On 13/01/2014 12:34, Michael Ring wrote: I had a look at armv6m yesterday evening, parts of my code run fine in gdb, the code crashes in the init of a procedure when trying to prepare the access to contents of a set. The address of the set seems to get calculated totally wrong ending up in a memory access at the end of the chip's address range. Not sure if this is related to your problem, I will try to boil down the example to a bare minimum to see where the generated code differs between armv7m and armv6m. Thanks a lot, Michael! ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On 13/01/14 13:36, Fred van Stappen wrote: [...] Hello Lucaz /// why not just : @soundtouch_createInstance := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); Get that error : libSoundTouch.pas(56,5) Error: Can't assign values to an address This (@syntax) is in (OBJ)FPC mode, your example is Delphi mode. http://wiki.freepascal.org/Lazarus/FPC_Libraries#Loadlibrary_-_dynamically_loading_a_dynamic_library http://forum.lazarus.freepascal.org/index.php?topic=1148.0 OK I stand corrected, re. the pointer() cast... but then why not declare in a public header for this wrapper: type TSoundtouchCreateInstanceProc = procedure; then soundtouch_createinstance := TSoundtouchCreateInstanceProc(DynLibs.GetProcedureAddress(...)); (nb. delphi mode) ? -L. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Does TBufDataSet support Blob or memo field?
All the other usual types (e.g. integer, string, datetime) work except ftMemo and ftblob. Yes, I have used POST Dennis LacaK wrote: AFAIR this is so. (we can call it bug ;-)) Data are not there until you Post record. After Post you will see data there, right? -Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
From: fi...@hotmail.com To: fpc-pascal@lists.freepascal.org Date: Mon, 13 Jan 2014 17:33:47 +0100 Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() Hello and many thanks to help. Here demo to show the problem (i hope). https://sites.google.com/site/fiensprototyping/dynlib_vs_windows.zip There is a program : test.pas It uses a external library soundtouch_2.dll. There are 2 wrappers : soundtouch_windows.pas (who uses windows unit) and soundtouch_dynlib.pas (who uses dynlib unit) There are also 4 binaries : test_windows_fpc262.exe = OK, works (use soundtouch_windows.pas and compiled with fpc 262) test_windows_fpc271.exe = NO, does NOT work (use soundtouch_windows.pas and compiled with fpc 271) test_dynlib_fpc262.exe = NO, does NOT work (use soundtouch_dynlib.pas and compiled with fpc 262) test_windows_fpc271.exe = NO, does NOT work (use soundtouch_windows.pas and compiled with fpc 271) You may test the prog with soundtouch_windows.pas or soundtouch_dynlib.pas (uncomment the one you want in use section). Many thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal Oops, forget about the 2.7.1. fpc binaries... (a 64 bit compiler was use in place of 32 bit)). So, only take care about : test_windows_fpc262.exe = OK, works (use soundtouch_windows.pas and compiled with fpc 262) test_dynlib_fpc262.exe = NO, does NOT work (use soundtouch_dynlib.pas and compiled with fpc 262) Many thanks. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Does TBufDataSet support Blob or memo field?
All the other usual types (e.g. integer, string, datetime) work Yes it is expected behaviorexcept ftMemo and ftblob. Yes it is not consistent and from my POV it is bug.I will look (next week or two) if it can be fixed, but I have doubts, that it will not be so easy :-))-Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On 13 Jan 2014, at 17:33, Fred van Stappen wrote: Hello and many thanks to help. Here demo to show the problem (i hope). https://sites.google.com/site/fiensprototyping/dynlib_vs_windows.zip in the dynlibs version, why do you use `PChar(1)` or `PChar(2)` [or ] instead of the name of the function as the second argument in GetProcAddress()? Perhaps try `GetProcAddress(LibHandle, 'soundtouch_clear');` on line 54 and modify the rest in a similar fashion? Hope it helps. -- Ewald ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
From: ew...@yellowcouch.org Date: Mon, 13 Jan 2014 21:25:27 +0100 To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress() On 13 Jan 2014, at 17:33, Fred van Stappen wrote:Hello and many thanks to help. Here demo to show the problem (i hope). https://sites.google.com/site/fiensprototyping/dynlib_vs_windows.zip in the dynlibs version, why do you use `PChar(1)` or `PChar(2)` [or ] instead of the name of the function as the second argument in GetProcAddress()? Perhaps try `GetProcAddress(LibHandle, 'soundtouch_clear');` on line 54 and modify the rest in a similar fashion? Hope it helps.--Ewald ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal Yep Ewald, many thank to help us ( and me). The SoundTouch.dll uses index to call the procedures. Like that : [Ordinal/Name Pointer] [ 0] soundtouch_clear [ 1] soundtouch_createInstance [ 2] soundtouch_destroyInstance try `GetProcAddress(LibHandle, 'soundtouch_clear'); I have try that, but it does not work...` ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
On 13 Jan 2014, at 23:06, Fred van Stappen wrote: The SoundTouch.dll uses index to call the procedures. Like that : [Ordinal/Name Pointer] [ 0] soundtouch_clear [ 1] soundtouch_createInstance [ 2] soundtouch_destroyInstance That explains why it works in windows probably, there you can specify an index to go with your exported procedures IIRC. I don't know if this is possible though on *nix. Have a look at http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx ; there it says that if you pass in a pointer with value where the high order word is zero, it is interpreted as an ordinal value. The same does not apply to the dynlibs version. try `GetProcAddress(LibHandle, 'soundtouch_clear'); I have try that, but it does not work...` What is the result of the call (GetProcAddress)? nil? if so then try to find the names of the symbols defined in the shared object (nm comes to mind). Now, for the windows version, I don't know what underlying mechanism dynlibs uses under windows, so I'm afraid I can't really comment on that platform, except that you could try a similar approach as on linux (use symbol names instead of indices). OTOH it could (?) be that the the compiler inserts code to typecast PChar(1) to a string, which could result in an access violation (try `var a: string; a:= pchar(1);` to try it out ;-) ). -- Ewald ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
fred, can you please adjust your quoting to use the standard '' for previous responses and then add your response below? you do add your response below but the quote is the exact of the previous and it is very hard to read only your responses when the previous is not prefixed by ''... thanks! ;) -- NOTE: No off-list assistance is given without prior approval. Please keep mailing list traffic on the list unless private contact is specifically requested and granted. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Profiling ARM targets
Thanks, I will give them a go. -b On Fri, Jan 10, 2014 at 10:36 PM, Jonas Maebe jonas.ma...@elis.ugent.bewrote: On 10 Jan 2014, at 01:13, Bruce Tulloch wrote: What is the recommended way to profile FPC applications run on ARM targets Callgrind and cachegrind (both part of Valgrind) are probably the best options. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal