Add OpenMPI rpath and LD_LIBRARY_PATH export for reliable linking

- Export OMPI_ROOT/lib64 in LD_LIBRARY_PATH so mpicxx finds its runtime libs
- Add -Wl,-rpath to embed OpenMPI lib64 path in executables for runtime
- Replace hardcoded paths with OMPI_ROOT variable

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-28 22:43:57 +08:00
parent 516cdea502
commit 6ca9fece2e

View File

@@ -1,8 +1,14 @@
## GCC version with OpenMPI and OpenBLAS
filein = -I/usr/include/ -I/usr/mpi/gcc/openmpi-4.1.9a1/include
OMPI_ROOT = /usr/mpi/gcc/openmpi-4.1.9a1
## Ensure mpicxx and final executables find OpenMPI libs at build- and runtime
export LD_LIBRARY_PATH := $(OMPI_ROOT)/lib64:$(LD_LIBRARY_PATH)
filein = -I/usr/include/ -I$(OMPI_ROOT)/include
## OpenBLAS (OpenMP variant) + gfortran runtime
LDLIBS = -lopenblaso -lgfortran -lpthread -lm -ldl -lgomp
## -Wl,-rpath ensures ABE / TwoPunctureABE find libmpi at runtime without LD_LIBRARY_PATH
LDLIBS = -Wl,-rpath,$(OMPI_ROOT)/lib64 -lopenblaso -lgfortran -lpthread -lm -ldl -lgomp
## Memory allocator switch
## 0 (default) : use system default allocator (ptmalloc)