[fpc-devel] link search order

Tomas Hajny XHajT03 at hajny.biz
Fri Feb 22 16:59:06 CET 2013


On Fri, February 22, 2013 16:33, Vittorio Giovara wrote:


Hi,

> yes I was talking about linux. I didn't include much information because I
> didn't want to confuse people with details.
>
> In this branch of Hedgewars
> https://code.google.com/p/hedgewars/source/list?name=physfslayer we are
> using physfs library version 2.1.0.
> However many people out there have version 2.0.3 installed and (of course)
> it doesn't contain many of the APIs present in 2.1.0.
> So when libphysfs is not found (or an old one is detected) we provide a
> copy of the right physfs and have CMake (our build system) compile and
> install it. However even if I hardcode the right path of the right library
> of the right version, the installed system library takes precedence, and
> thus if another version of physfs is installed, hedgewars doesn't link any
> more.
>
> I would refrain from using a different library name; looking at the
> generated link.res file it seems that the first lib search path is
> /urs/lib
> and /lib and the custom one (where the right libphysfs resides) is found
> only later on. Is there a way to prevent this? I tried to play with the
> -Xd
> flag but the result didn't change.

I don't know enough about the library path setting (I leave commenting on
this to others). However, if you require a specific version number of a
library (and even distribute that version with your code), explicitly
linking to that library version seems to be the appropriate solution from
my point of view. Another option may be linking the respective library
statically.

Tomas





More information about the fpc-devel mailing list