Background
I got very strange issue when Compiling R from source code, where I was told the libraries that libgomp.so depends could not be found.
I am working on a remote server without sudo privilege so I compiled everything form source code and generally place everything under $HOME/.local.
I recently compiled my own gcc-11 with the gcc-7.5 provided by the server. And I get error when trying to compile R from the new gcc-11.
Root Cause
The file $HOME/.local/lib/libgomp.so1 was, very suprisingly, a soft link to $HOME/local/lib/libomp.so2.
This unconventional setup was likely causing the linker errors, as the R compilation process was expecting the genuine libgomp.so3 library and not the LLVM version.
Why the Misconfiguration
- Manual intervention in an attempt to patch another issue.
- A mix-up during package management or installation.
- A misconfiguration during a custom build of GCC or another software.
Resolution
- The problematic symlink (
libgomp.sopointing tolibomp.so) was identified and renamed. - After correcting the symlink issue, the R source code compilation proceeded without the earlier errors.
Future Precautions
- Document any expedients or shortcuts taken during system configuration.
- Use version control for system configurations or personal scripts.
- Periodically review and audit custom configurations.
- Employ isolated environments for experimental work or testing.
- Regularly back up systems, especially before making major changes.
Diagnostic Tools
ldd: Checks the shared library dependencies of a binary or library. This tool initially indicated thatlibomp.sowasn’t recognized as a dynamic executable.file: Determines the type of a given file. This tool confirmed thatlibomp.sowas an ELF 64-bit shared object but hinted at a possible FreeBSD targeting4.objdump: Displays information about object files. It can show dynamic linking information when used with the-pflag.readelf: Provides detailed information about ELF binaries and shared objects. The-doption can display dynamic linking information, providing insights similar toldd.
Conclusion
The issue underscores the importance of ensuring system configurations, especially library linkages, are correctly set up. Utilizing diagnostic tools such as ldd, file, objdump, and readelf proved invaluable in identifying the problem. An unconventional symlink led to unexpected compilation issues, highlighting the need for careful documentation and periodic review of system modifications.