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

fredvs fiens at hotmail.com
Sat Mar 19 22:39:52 CET 2016

@ 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:



Ok, ok, understood and wow.

Added in code:

    Function dlopen(filename: PChar; flags: cint): Pointer; cdecl; external;
    Function dlclose(handle: Pointer): cint; cdecl; external;
    Function dlsym(handle: Pointer; Name: PChar): Pointer; cdecl; external;
    Function dlerror: PChar; cdecl; external;

and, magic, it works. ;-)

Now the result:

In code:

procedure loadmylib(lib : pchar);
ap1, ap2, ap3 : pointer;
/// FreeBSD functions:
ap1 := dlopen(Pchar(lib), 0);
if ap1 <> nil then
writeln('dlopen() is OK') else
writeln('dlopen() is NOT OK') ;

ap2 := dlsym(ap1, Pchar('mp4ff_open_read');
if ap2 <> nil then
writeln('dlsym() is OK') else
writeln('dlsym() is NOT OK') ;



---> result:
writeln('dlopen() is OK')
writeln('dlsym() is OK')
_ (no error)

Now with DynLibs:

procedure loadmylib(lib : pchar);
ap1: pointer;
hn : integer;
/// with dynlibs
hn := dynlibs.loadlibrary(Pchar(lib));

if hn <> 0 then
writeln('loadlibrary() is OK') else
writeln('loadlibrary() is NOT OK') ;

ap1 := getprocedureaddress(hn, Pchar('mp4ff_open_read');

if ap1 <> nil then
writeln('getprocedureaddress() is OK') else
writeln('getprocedureaddress() is NOT OK') ;


--> result:

loadlibrary() is OK
getprocedureaddress() is NOT OK

Conclusion: Maybe getprocedureaddress() has problems.

PS: Other tips are welcome.


Many thanks ;-)
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Mangle-name-in-fpc-FreeBSD-tp5724528p5724585.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

More information about the fpc-pascal mailing list