On Red Hat Linux 9 how to solve the following `/usr/bin/ld: cannot find -l` errors? Knowing that I installed the mentioned dependencies in `~/rpm/x86_64/`.
```bash uv pip install iio==29 ``` ``` Using Python 3.14.4 environment at: .venv_x86-64 Resolved 1 package in 7ms × Failed to build `iio==29` ├─▶ The build backend returned an error ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit status: 1)
[stderr] <string>:55: SyntaxWarning: "\." is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\."? A raw string is also an option. /usr/bin/ld: cannot find -lpng /usr/bin/ld: cannot find -ljpeg /usr/bin/ld: cannot find -ltiff /usr/bin/ld: cannot find -lwebp collect2: error: ld returned 1 exit status error: command '/usr/bin/cc' failed with exit code 1
hint: Build failures usually indicate a problem with the package or the build environment ```
Jun 9, 9:20pm
The error /usr/bin/ld: cannot find -l<library> (e.g., -lpng, -ljpeg, -ltiff, -lwebp) means the linker (ld) cannot find the required static or shared libraries for libpng, libjpeg, libtiff, and libwebp. Even though you installed the dependencies in ~/rpm/x86_64/, the linker is not searching that directory for libraries.
Solution: Tell the Linker Where to Find the Libraries
1. Set LIBRARY_PATH and LD_LIBRARY_PATH
The linker (ld) and runtime linker use these environment variables to locate libraries.
bash
# For the current session (temporary)
export LIBRARY_PATH=~/rpm/x86_64/usr/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=~/rpm/x86_64/usr/lib:$LD_LIBRARY_PATH
# For permanent use, add these lines to your ~/.bashrc or ~/.bash_profile
echo 'export LIBRARY_PATH=~/rpm/x86_64/usr/lib:$LIBRARY_PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=~/rpm/x86_64/usr/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
Note:
LIBRARY_PATH is for compile-time linking.
LD_LIBRARY_PATH is for runtime linking.
2. Verify Library Files Exist
Ensure the .so (shared object) files for the missing libraries exist in ~/rpm/x86_64/usr/lib/:
bash
ls ~/rpm/x86_64/usr/lib/libpng*
ls ~/rpm/x86_64/usr/lib/libjpeg*
ls ~/rpm/x86_64/usr/lib/libtiff*
ls ~/rpm/x86_64/usr/lib/libwebp*
If they are missing, you need to install the development packages for these libraries (e.g., libpng-devel, libjpeg-turbo-devel, libtiff-devel, libwebp-devel) in your ~/rpm/x86_64/ directory.
3. Reinstall Dependencies in the Correct Location
If the libraries are missing, reinstall them in ~/rpm/x86_64/ using rpm or yum:
bash
# Example for libpng (adjust for your RPMs)
rpm -ivh --prefix=~/rpm/x86_64 libpng-devel-*.rpm
rpm -ivh --prefix=~/rpm/x86_64 libjpeg-turbo-devel-*.rpm
rpm -ivh --prefix=~/rpm/x86_64 libtiff-devel-*.rpm
rpm -ivh --prefix=~/rpm/x86_64 libwebp-devel-*.rpm
Note: Use --prefix to install RPMs in a custom directory.
4. Pass Linker Flags Explicitly
If the above doesn’t work, explicitly pass the library paths to the build process:
bash
# Set these before running `uv pip install iio==29`
export CFLAGS="-I~/rpm/x86_64/usr/include"
export LDFLAGS="-L~/rpm/x86_64/usr/lib -lpng -ljpeg -ltiff -lwebp"
uv pip install iio==29
5. Check for 32-bit vs 64-bit Mismatch
Ensure all libraries are 64-bit (since you’re using x86_64). If you accidentally installed 32-bit libraries, the linker will fail.
bash
file ~/rpm/x86_64/usr/lib/libpng.so*
Output should include ELF 64-bit.
6. Debugging the Linker
To see where the linker is searching for libraries: