<div dir="ltr"><div><div><div><div><div>Hi All,<br><br></div>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:<br>
<br></div>PURPOSE<br><br></div>I want to link to a C library that does NOT start with "lib" prefix. The library's name is <span style="font-family:courier new,monospace">thostmduserapi.so</span><br><br></div>
PROCEDURE<br><br></div>I tried to use<span style="font-family:courier new,monospace"> {$linklib thostmduserapi},</span> fpc complains: <br><div><div><div><div><div><br><span style="font-family:courier new,monospace">ld: cannot find -lthostmduserapi</span><br>
<br></div><div>If I rename <span style="font-family:courier new,monospace">thostmduserapi.so</span> to <span style="font-family:courier new,monospace">libthostmduserapi.so<span style="font-family:arial,helvetica,sans-serif">, the problem is solved, however this is exactly what I *don't* want -- add lib prefix to so file.<br>
<br></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">After checking the ld man page, I learned that:<br><span style="color:rgb(0,0,255)"><span style="background-color:rgb(204,204,204)"><br>
</span></span><span style="font-family:courier new,monospace"><span style="color:rgb(0,0,255)"><span style="background-color:rgb(204,204,204)">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.</span></span><br>
<br></span></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace">So I tried: {$linklib :thostmduserapi.so}<span style="font-family:arial,helvetica,sans-serif">. This time, fpc complains:</span><br>
</span></span></span><br><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ld: cannot find thostmduserapi</span><br>
<br></span></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">I added <span style="font-family:courier new,monospace">-st </span>to fpc, and get the following in the generated link.res file:</span><br>
<br>INPUT(<br>-l:thostmduserapi<br>-lstdc++<br>-lgcc_s<br>)<br><br></span></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">I manually changed the script to<span style="font-family:courier new,monospace"> -l:thostmduserapi.so</span>, and it linked without problem!<br>
<br></span></span></span></span></div><div><span style="font-family:arial,helvetica,sans-serif">I think the process of generating link script is buggy, because it does not conform with ld specification.<br><br>Regards,<br>
</span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">Xiangrong</span><br>
</span></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><br></span></span></span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:courier new,monospace"><br>
<br></span><br></span></span></div></div></div></div></div></div>