Wrong link search order causes linking failure
Original Reporter info from Mantis: koda
-
Reporter name:
Original Reporter info from Mantis: koda
- Reporter name:
Description:
I'm trying to link my program with a library that has not yet been released but when that library is installed from an older version, no matter what I do it causes linking failure.
More in particular, in this branch of Hedgewars
https://code.google.com/p/hedgewars/source/list?name=3Dphysfslayer 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
at the right version with -k, the installed system library takes precedence, and
thus if another version of physfs is installed, Hedgewars doesn't link any
more.
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 and I would prefer not having to edit fpc.cfg.
I was able to reproduce this problem on Linux only but theoretically it could happen anywhere.
Additional information:
Originally from a discussion on the mailing list
http://lists.freepascal.org/lists/fpc-devel/2013-February/031492.html
Mantis conversion info:
- Mantis ID: 23948
- OS: Linux
- OS Build: 12.04
- Platform: Ubuntu
- Version: 2.4.4
- Monitored by: » koda (koda)