[fpc-pascal] linking and using dynamic libraries on amd64

Tony Whyman tony.whyman at mccallumwhyman.com
Thu Feb 12 10:03:55 CET 2015


Marc,

If your running on a *nix system then you probably want "cdecl" rather
than "stdcall"

Regards

Tony Whyman
MWA

On 12/02/15 04:54, Marc Santhoff wrote:
> On Do, 2015-02-12 at 00:42 +0100, Marc Santhoff wrote:
>> Hi,
>>
>> when I try to run a program that dynamically links an external .so
>> library it throws a SIGSEGV error at startup. That seems to happen while
>> loading the library before any code of mine is exeuted.
>>
>> The library is pulled into it by a header translation from C to Pascal.
>> The functions are declared "...; stdcall; external libname name xxx'.
>> This way it worked on i386.
>>
>> When the error occurs the ASM window pops up, which is not very helpful
>> for me.
>>
>> There may be a minor change in the lib source itself, but compiling the
>> header and linking works OK. I have no idea how to check besides getting
>> the older versions source and try again. Will try if nothing else is
>> fishy.
> I did test the old library and the error is the same.
>
> GDB tells me it happens when starting at BEGIN and running the init function
> of the library. That function does not have any arguments, I'm assuming
> "something else" then ...
>
>> My questions:
>>
>> Is there any difference in declaring external functions between 32 and
>> 64 bit mode?
>>
>> How can I debug what is happening? Will compiling the library having an
>> external debug file work when debugging from Lazarus?
>>
>> Any hints for diagnosing what's going wrong are very welcome.
>>
>>
>>
>> Some data points:
>> fpc 2.6.2 x86_64
>> library is compiled to 64 bit
>> FreeBSD 9.1-STABLE amd64
>>
>> Best regards,
>> Marc 
>>




More information about the fpc-pascal mailing list