Sorry chenyuchih, perhaps I was too brief. Longer version.
As a general rule, we don't put libraries along side an executable like windows does because Linux really tries to enforce sharing. So, if you are looking for a preinstalled "general purpose" library that's been installed properly, its likely to be in one of that short list of locations. So, if you know the name, search there.
Some applications do keep their own private libraries tucked away where only they will find them, thats OK, if they are so tucked away, you probably should not be using them anyway.
If you use a tool like strace you will see that most applications start up trying to open desired libraries, one dir after another until it finds what it needs. Its sounds like a laborous process but its the way it works !
The other way, using ldconfig ? That snipit of code I posted was too brief, if you need to take that approach, here is more of it ....
uses LazUTF8, SysUtils, {$ifdef linux}Process,{$endif} LazFileUtils, Forms, lazlogger;
......
function THunspell.FindLibrary(out FullName : ANSIString):boolean;
var
{$ifdef LINUX} I : integer = 1; {$endif}
{$ifndef LINUX}
Info : TSearchRec;
Mask : ANSIString;
{$endif}
begin
Result := False;
{$IFDEF LINUX}
// Assumes ldconfig always returns same format, better than searching several dirs
if RunCommand('/bin/bash',['-c','ldconfig -p | grep hunspell'], FullName) then begin
while UTF8Pos(' ', FullName, I) <> 0 do inc(I);
if I=1 then exit();
UTF8Delete(FullName, 1, I-1);
UTF8Delete(FullName, UTF8Pos(#10, FullName, 1), 1);
Result := True;
end else
if RunCommand('/bin/bash',['-c','/sbin/ldconfig -p | grep hunspell'], FullName) then begin
while UTF8Pos(' ', FullName, I) <> 0 do inc(I);
if I=1 then exit();
UTF8Delete(FullName, 1, I-1);
UTF8Delete(FullName, UTF8Pos(#10, FullName, 1), 1);
Result := True;
end;
{$ENDIF}
......
Davo