[fpc-pascal] Can someone please explain the linker to me?
sysrpl at gmail.com
Wed Jun 5 21:58:52 CEST 2013
I am having a lot of problems due to me not understanding why the linker
acts the way it does and would appreciate it if someone could explain to me
why or how some of the my problem are occurring. I'll provide some examples.
Example on Linux
I am linking to openssl which I assume is already provided on most if not
all distros. On 12.04 32 bit I was using "external 'libssl.so'" at the end
of all my function imports which worked fine.
On 13.04 this broke and I found there was no libssl.so in /usr/lib but
there was a libssl.so.1.0.0 in /lib/x86_64-linux-gnu/libssl.so.1.0.0. I
then created a symbolic link to that shared object in my /usr/lib folder
named libssl.so and everything worked, or so I thought.
When I tried to use the crypto functions again on 13.04 the linker said it
couldn't link "libcrypto", so it would seem that on one distro the crypto
function are in libssl while in another they are in libcrypto .... okay I
guess that happens.
But the the weird thing is I created a symbolic link
to /usr/lib/libcrypto.so.1.0.0 and when I switch my pascal code to use
"external 'libcrypto.so.1.0.0'" I still get the linking error stating that
libcrypto could not be found. I had to create the symbolic link as
/iusr/lib/libcrypto.so and then it worked.
Having a thought I renamed my external to this garbage "external
'libcrypto.so.1.2.asdasd'" and it compiled and everything still works. So
it would seem that the linker is is ignoring everything outside the word
'crypto' and requires I specifically name the files 'libcrypto.so' and
So basically ...
libssl = 'libssl.so.1.0.0';
libcrypto = 'libcrypto.so.1.0.0';
function SSL_library_init: Integer; cdecl; external libssl;
function MD5_Init(out context: TMD5Ctx): LongBool; cdecl; external
Will not link because the linker wants to find 'libssl' and 'libcrypto'. I
have to create those specific symbolic links (a symbolic link or even a
copied file named libssl.so.1.0.0 does not link). Why is the linker forcing
me to use that specific names and why does free pascal ignore my external
name (I can write libssl = 'libssl.so.asdfga'; and it still links so long
as libssl.so exists in my /usr/lib directory)?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal