Linker problems with clang /usr/local/lib

Dimitry Andric dim at FreeBSD.org
Sun Jan 22 20:42:35 UTC 2017


On 22 Jan 2017, at 21:29, Johannes Lundberg <johalun0 at gmail.com> wrote:
> 
> How can I make 'cc' (/usr/bin/ld) look for libraries in /usr/local/lib
> without having to specify environment or command line variables?
> 
> I got "/usr/local/lib" in /etc/ld.so.conf and /var/run/ld-elf.so.hints.
> 
> /sbin/ldconfig -l xxx can find library xxx in /usr/local/lib
> 
> /usr/bin/ld can not.
> 
> This is a problem when building Rust crates with Cargo which does not care
> about env variables like LDFLAGS. I can however override the linker and use
> 'gcc' which solves the problem but I assume it should be possible to get
> clang (cc) to look in /usr/local/lib as well.
> 
> Anyone got any ideas?

Create a wrapper script that adds -L/usr/local/lib to the link command
line, and invokes the 'real' cc or ld.  Then either let Rust call the
wrappers, or put them in a directory that is in front of your PATH.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20170122/ad3f5e18/attachment.sig>


More information about the freebsd-current mailing list