[fpc-pascal] Re: Problems linking C library on Linux (*.so & *.a files)

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Feb 12 20:28:04 CET 2009


On 12 Feb 2009, at 20:12, Guillermo Martínez Jiménez wrote:

>> On 10 Feb 2009, at 19:30, Guillermo Martínez Jiménez wrote:
>>
>>> I tried to link that library using "{$linklib alleg_unsharable}". It
>>> linked without error but it raises the same runtime error. Then I
>>> tried deleting the "{$...}" and adding "-klalleg_unsharable" at
>>> command line but then it said:
>>>
>>> ...
>>> /usr/bin/ld: lalleg_unsharable: No such file: No such file or
>>> directory
>>> test.pp(17,1) Error: Error while linking
>>> ...
>>
>> Linking with a static library works the same way as linking with an
>> object file: Either -k/full/path/to/library.a, or {$l library.a} in
>> combination with -Fo/full/path/to/library.
>>
>> In principle, {$linklib xxx} or -klxxx in combination with -Fl would
>> also work if you use the -Xt parameter (so the linker looks for  
>> static
>> libraries -- but then it will try to link every single library
>> statically, which is probably not what you want).
>
> Thanks for the advices, Jonas. I've tried all the combinations but
> allways it returns the same runtime error.

Link time error, I guess. But according to your original message, the  
name of the library is liballeg_unshareable.a. So you would have to  
use -k liballeg_unshareable.a, not "-klalleg_unshareable.a". The  
linker only prepends "lib" if you use "-k-lalleg_unshareable.a" (note  
the extra "-"). And if you use it with {$l } in the source, you also  
need the full exact name: {$l liballeg_unshareable.a} (because you are  
linking like a regular object file in that case, not as a library).


Jonas


More information about the fpc-pascal mailing list