Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-21 Thread Sven Barth
Am 21.03.2016 13:57 schrieb "fredvs" : > > > Even on Win64 that would have been wrong as there TLibHandle is 64-bit as > well and it also defines MSWINDOWS. > > Hello Sven. > > I am unforgivable to not have seen that wrong declaration. > > And to not have deeply check code from other before to comm

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-21 Thread fredvs
> Even on Win64 that would have been wrong as there TLibHandle is 64-bit as well and it also defines MSWINDOWS. Hello Sven. I am unforgivable to not have seen that wrong declaration. And to not have deeply check code from other before to commit it. I apologize for all the noise. Fre;D -

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Sven Barth
Am 21.03.2016 00:33 schrieb "fredvs" : > > Aargh. > > Indeed, the declaration of variable for the library-handle was wrong. > And FreeBSD is more strait than Linux and Windows. Even on Win64 that would have been wrong as there TLibHandle is 64-bit as well and it also defines MSWINDOWS. Regard

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
Aargh. Indeed, the declaration of variable for the library-handle was wrong. And FreeBSD is more strait than Linux and Windows. I was focused on GetProcAddress but the bug was in LoadLibrary... ;-( Changing --> var lib_handle:TLibHandle=dynlibs.NilHandle; solves everything, even in FreeBSD.

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
>> Why do you use "hn: Intege"hn: Integer" instead of "hn: TLibHandle" > Excellent question... > Because of... fpc... > > In fpc 64 bit unix : result of dynlibs.loadlibrary() is... a integer. Ooops, How will I explain that ?... In the pascal header of the library that gives problems this is def

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Ewald
On 03/20/2016 05:32 PM, fredvs wrote: > >> Why do you use "hn: Intege"hn: Integer" instead of "hn: TLibHandle" > Excellent question... > Because of... fpc... > > In fpc 64 bit unix : result of dynlibs.loadlibrary() is... a integer. Well, if this is the case, then you should probably report a bug.

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
> That's totally OK, but the unit dynlibs is written for platform > independence and I'd like to be able to use it on FreeBSD and at least > Windows without having much $ifdefs and the like. Huh,... me too... I am sure that fpc team will find the solution. But, before it will be integrate into new

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 09:47 -0700, fredvs wrote: > Re-hello. > > To resume. > > Here what is working perfectly for me: > > {$IF DEFINED(freebsd)} > ... > var > ap1 : pointer; > begin > ap1 := dlopen(Pchar(mp4ff), 1); > Pointer(mp4ff_open_read) := dlsym(ap1, pchar('mp4ff_open_read')); > ...

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
Re-hello. To resume. Here what is working perfectly for me: {$IF DEFINED(freebsd)} ... var ap1 : pointer; begin ap1 := dlopen(Pchar(mp4ff), 1); Pointer(mp4ff_open_read) := dlsym(ap1, pchar('mp4ff_open_read')); ... {$else} ... var an1 : integer; begin an1 := DynLibs.SafeLoadLibrary(PCh

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
> For Fred: > You can check the names inside a dynamic liobrary using system tools: > nm -D /usr/lib/libipsec.so > nm -D /usr/local/lib/vlc/plugins/codec/libx264_plugin.so Thanks but... see my second mail in this topic... ;-) Fre;D - Many thanks ;-) -- View this message in context: http

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
>> Replacing all GetProcedureAdress() with dlsym() >> >> DOES THE TRICK ! ;-) > Uhm, are you sure about this? --> https://github.com/fredvs/uos Try SimplePlayer example (all FreeBSD libraries are included in uos package) --> choose /sound/test.m4a --> IT WORKS ;-) > Could you add a "writeln(dle

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 15:10 +0100, Marc Santhoff wrote: > On So, 2016-03-20 at 14:27 +0100, Ewald wrote: > > > Could this be related to pointer trucation? The man page of dlopen tells > > us that the return value is a pointer (hence the return value of > > LoadLibrary has the same width). In your e

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 14:27 +0100, Ewald wrote: > Could this be related to pointer trucation? The man page of dlopen tells > us that the return value is a pointer (hence the return value of > LoadLibrary has the same width). In your example you used an integer. Is > sizeof(Integer) = sizeof(Pointer

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Ewald
On 03/20/2016 01:11 PM, fredvs wrote: >> Or simply dlerror() like in the other program, should work. > OK. here code + result of GetProcedureAddress(), maybe it could help for > future fixes in fpc: > > GetProcedureAddress(hn, pchar('mp4ff_open_read'); > writeln(dlerror()); > > ---> Result: > > "I

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Ewald
On 03/20/2016 12:56 AM, fredvs wrote: > Re-hello (and last for tonight). > > Yep, yep, yep. > > Replacing all GetProcedureAdress() with dlsym() > > DOES THE TRICK ! ;-) Uhm, are you sure about this? I always thought GetProcedureAddress simply calls through to dlsym. If one works and the other does

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On So, 2016-03-20 at 05:11 -0700, fredvs wrote: > >> ap1 := dlopen(Pchar(lib), 0); > > > Here you are using 0 for three mode argument. One difference I can see > > ist that uysing dynlibs.pas the mode is RTLD_LAZY like it should be, but > > that constant is defined as 1. > > Huh, indeed, 0 is wo

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread fredvs
>> ap1 := dlopen(Pchar(lib), 0); > Here you are using 0 for three mode argument. One difference I can see > ist that uysing dynlibs.pas the mode is RTLD_LAZY like it should be, but > that constant is defined as 1. Huh, indeed, 0 is working in Linux but not in FreeBSD --> changed to 1 and all ok

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-20 Thread Marc Santhoff
On Sa, 2016-03-19 at 14:39 -0700, fredvs wrote: > @ Marco and Marc thanks for help. > > Sorry I do not have easy internet connection so I worked by my side. > > I will try your tips. > > By the way, here are my investigations: > > > > Hello. > > Ok, ok, un

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Sven Barth
Am 20.03.2016 00:57 schrieb "fredvs" : > PS: This is a great victory who will solve (I hope) other library-related > problems. > PS2: Are there limitations of using dlsym() vs GetProcedureAdress() ? > PS3: If dlsym() is cross-platform too, should I update all my codes that use > GetProcedureAdress(

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
Re-hello (and last for tonight). Yep, yep, yep. Replacing all GetProcedureAdress() with dlsym() DOES THE TRICK ! ;-) (but dlopen() is needed in place of Loadlibrary()) Excellent tip. Many, many, many thanks for help. (And, maybe, a check for DynLibs.GetProcedureAdress() is needed for FreeBSD

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
Just quick before they cut the signal... Could dlsym(ap1, Pchar('mp4ff_open_read') be used in place of getprocedureaddress(hn, Pchar('mp4ff_open_read') ? Because, if dlsym() works, maybe replacing all getprocedureaddress() with dlsym() will work? And can loadlibrary() be used by dlsym() ( or d

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
OOOps, in previos mail: Thanks to Ewald, Marco and Marc. Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Mangle-name-in-fpc-FreeBSD-tp5724528p5724586.html Sent from the Free Pascal - General mailing list archive at Nabble.com. _

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
@ Marco and Marc thanks for help. Sorry I do not have easy internet connection so I worked by my side. I will try your tips. By the way, here are my investigations: Hello. Ok, ok, understood and wow. Added in code: Function dlopen(filename: PChar; fl

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marc Santhoff
On Mo, 2016-03-14 at 08:15 -0700, fredvs wrote: > Hello. > > I have problem to access methods from a C library. > > For FreeBSD, the methods cannot be accessed (but ok for Linux and Windows). > > In FreeBSD, LoadLibrary(aac.so) is working but all GetProcAdress() for each > method fail. > Does a

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Ewald
On 03/19/2016 08:53 PM, Marco van de Voort wrote: > In our previous episode, Ewald said: >>> Re-huh..., it should be a great plus if a dlerror() was implemented in fpc >>> too. >>> >>> But maybe I am missing something, maybe dlopen(), dlsym() and dlerror() can >>> be done by pascal code (and not vi

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Ewald
On 03/19/2016 08:29 PM, fredvs wrote: >> dlopen, dlsym and dlerror are *functions*, not console commands. Well, I >> never tried the latter, but it appears they are not on your system ;-) >> Now, I don't know where exactly these functions are declared (in which >> unit, that is), but for debugging

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marco van de Voort
In our previous episode, Ewald said: > > Re-huh..., it should be a great plus if a dlerror() was implemented in fpc > > too. > > > > But maybe I am missing something, maybe dlopen(), dlsym() and dlerror() can > > be done by pascal code (and not via console, like I try). > > > dlopen, dlsym and dler

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
> dlopen, dlsym and dlerror are *functions*, not console commands. Well, I > never tried the latter, but it appears they are not on your system ;-) > Now, I don't know where exactly these functions are declared (in which > unit, that is), but for debugging purposes, just add >Function dlopen(

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Ewald
On 03/19/2016 07:49 PM, fredvs wrote: > Hello Marc. > > Huh, I have a dummy question... > > How do you use dlopen(), dlsym() and dlerror() ? > > On console, with -> > > fred@freebsd> dlopen('/root/mylib.so') > > Result = "Illegal command name..." > >> call dlerror() after the failing dlsym(). It sh

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
Hello Marc. Huh, I have a dummy question... How do you use dlopen(), dlsym() and dlerror() ? On console, with -> fred@freebsd> dlopen('/root/mylib.so') Result = "Illegal command name..." > call dlerror() after the failing dlsym(). It should tell _why_ the call > failed. Re-huh..., it should

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
> Would you mind telling the result of dlerror()? OK, I will follow your tips. Write you later with the result. > There are in fact different C compilers which are all able to compile C or C++. Yes and nearly all that compilers are the same (why not use sym-link?) -> "Why not use sym-link in

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marc Santhoff
On Fr, 2016-03-18 at 16:34 -0700, fredvs wrote: > > When following the procedure calls I find: > ... > > Hello Mark. > > Thanks for your light. > > Huh, yes, IMO, there is something strange in dlsym/FreeBSD. Would you mind telling the result of dlerror()? > And asking something about C librar

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread Marc Santhoff
On Do, 2016-03-17 at 04:27 -0700, fredvs wrote: > > it would be helpful to see the code fragments in question. > > The declaration of the external functions if any and the code calling > > LoadLibrary() and GetProcAddress(). > > Hello Mark and thanks for help. > > Here declaration to load-getpro

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-19 Thread fredvs
> it would be helpful to see the code fragments in question. > The declaration of the external functions if any and the code calling > LoadLibrary() and GetProcAddress(). Hello Mark and thanks for help. Here declaration to load-getprocess: - va

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-18 Thread fredvs
> When following the procedure calls I find: ... Hello Mark. Thanks for your light. Huh, yes, IMO, there is something strange in dlsym/FreeBSD. And asking something about C library/compiler is extremely sensible there on FreeBSD forum. (FreeBSD needs 8 (!) different C compilers (clang, c++, CC

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-15 Thread fredvs
> You could check with objdump or nm what the exported symbols look like in the library. There are some systems that export > C functions with a leading '_' for example. Hello Sven and thanks for answer. Here result of nm on FreeBSD 64.

Re: [fpc-pascal] Mangle name in fpc-FreeBSD ?

2016-03-14 Thread Sven Barth
Am 14.03.2016 16:16 schrieb "fredvs" : > > Hello. > > I have problem to access methods from a C library. > > For FreeBSD, the methods cannot be accessed (but ok for Linux and Windows). > > In FreeBSD, LoadLibrary(aac.so) is working but all GetProcAdress() for each > method fail. > > I already ask h