First of all I was surprised that Direct SQL compiled flawlessly in FreePascal! Then I noticed I couldn't connect to my server and traced the problem back to some obviously unfinished line of code.
Problem 1:
The problem you have is that 'errno' is defined in the ISO standard as an assignable l-value and can be either a MACRO or a variable. This is a bad starting point for any Pascal Linker.
Solution 1:
Looking through the web I found that the GNU implementation of the ISO standard exports the function '__errno_location()' which returns the address of that int. So I deleted your global variable 'errno: Integer' and added "function errno: PInteger; cdecl; external 'libc.so.6' name '__errno_location';". In addition all the references to "errno" have to be changed to "errno^".
Problem 2:
connect still didn't seem to work and if errno^ returned reliable values it was due to an 'invalid parameter'.
Solution 2:
As the socket wasn't -1 and the address length was 16 it had to be the address itself. Looking at the declaration of connect I got a bit nervous about the "const" keyword cause it can be used by the compiler to transfer values in registers while we explicitly need a pointer here. So I changed this to "var" and it seems to do the trick.
Thank you for this great library and making it as compatible as it can be. I'm looking forward to the next release.
Marco