Hi All,
I use $linklib to link my fpc program with a C++ so file. I found that the $linklib directive does NOT conform with ld specification. This is what I did and found:
PURPOSE
I want to link to a C library that does NOT start with "lib" prefix. The library's name is thostmduserapi.so
PROCEDURE
I tried to use {$linklib thostmduserapi}, fpc complains:
ld: cannot find -lthostmduserapi
If I rename thostmduserapi.so to libthostmduserapi.so, the problem is solved, however this is exactly what I *don't* want -- add lib prefix to so file.
After checking the ld man page, I learned that:
If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a.
So I tried: {$linklib :thostmduserapi.so}. This time, fpc complains:
ld: cannot find thostmduserapi
I added -st to fpc, and get the following in the generated link.res file:
INPUT(
-l:thostmduserapi
-lstdc++
-lgcc_s
)
I manually changed the script to -l:thostmduserapi.so, and it linked without problem!
I think the process of generating link script is buggy, because it does not conform with ld specification.
Regards,
Xiangrong
