0

I'm trying to get ld to see a path where I have a .so installed. There's another similar post here which I've been following.

In my case, I need the paths controlled by environment variable, just like the other person posting.

There's also another answer in a different post which recommends using pkg-config to auto-find the paths needed. But again, that won't work for me because it'd require changing source code, and the solution needs to be configuration-based (environment variable, ideally).

What I Tried

Setting LIBRARY_PATH and/or LD_LIBRARY_PATH to the directory doesn't work.

Using -L does work but I can't use it, because the solution must be configuration-based (no execution flags)

ld -lxcb-keysyms --verbose -L`echo $LD_LIBRARY_PATH`  # This finds the path I need
LIBRARY_PATH=$LD_LIBRARY_PATH ld -lxcb-keysyms --verbose  # This doesn't find it.

I've also tried modifying my path to include or not include the "lib64" folder in the environment variable like one of the answers pointed out. This doesn't work. Anyone know what I need to do to get this working?

System specs

$lsb_release --all
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core)
Release:        7.6.1810
Codename:       Core
ColinKennedy
  • 828
  • 7
  • 24
  • It's unclear why you have a problem. Why do you consider `-Ldir` an "execution flag" but not `-lname`? `LIBRARY_PATH` has no meaning for `ld` but is significant for `gcc`. So why don't you link using `gcc`? And you'd have to be assigning or appending `/the/right/path` to `LIBRARY_PATH` at some point anyhow in the inherited environment of the `ld` process, if it *was* significant; so why can't you assign `THE_RIGHT_PATH=/the/right/path`at the same point and then run `ld ... $(THE_RIGHT_PATH)/libxcb-keysyms.so ...`? – Mike Kinghan May 12 '20 at 09:10
  • I'm still catching up on the docs for all this so I probably have some concepts confused. The tool I'm compiling with `make` already defines `-lname` which is why I don't mind that it's there. But adding `-L` would require me to manually add it via `LDFLAGS` or patch the Makefile directly. Instead of doing something that'd dependent on the Makefile, I'd like to know how to set my environment so I don't need to change any of the program's source code. – ColinKennedy May 12 '20 at 16:00
  • [This is the project, by the way](https://github.com/baskerville/sxhkd/blob/master/Makefile#L8) – ColinKennedy May 12 '20 at 16:00
  • the `ld(1)` man page seems to indicate that `LD_RUN_PATH` might serve your need. – ranga May 17 '20 at 02:09

0 Answers0