diff -ruN a/cmake/InstallDirs.cmake b/cmake/InstallDirs.cmake
--- a/cmake/InstallDirs.cmake	2026-11-23 10:19:50.070172639 +0300
+++ b/cmake/InstallDirs.cmake	2026-11-23 10:20:14.607866372 +0300
@@ -29,7 +29,9 @@
 # --------------------------------------------------------------------	
 
 set(BINDIR "${CMAKE_INSTALL_POSTFIX}bin") #binary subdirectory in install location
-set(LIBDIR "${CMAKE_INSTALL_POSTFIX}lib") #shared library subdirectory in install location
+# Gentoo: follow CMAKE_INSTALL_LIBDIR (set by the toolchain/package manager,
+# e.g. lib64) rather than hardcoding "lib".
+set(LIBDIR "${CMAKE_INSTALL_POSTFIX}${CMAKE_INSTALL_LIBDIR}") #shared library subdirectory in install location
 # Gentoo: keep the data tree under $(prefix)/share/ambertools/dat so that
 # $AMBERHOME/dat lookups still work with AMBERHOME=/usr/share/ambertools.
 set(DATADIR "${CMAKE_INSTALL_POSTFIX}share/ambertools/dat") #subdirectory for programs' data files
diff -ruN a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt	2026-11-23 10:19:50.069196537 +0300
+++ b/CMakeLists.txt	2026-11-23 10:20:55.281483348 +0300
@@ -38,8 +38,10 @@
 #---------------------------------------------------------------------------------------------------------------------------------------------------------------------
 # Initial configuration
 
-# Use prefix/lib rather than prefix/lib64; if it was unset, then it is system-dependent
-set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "Library install directory" FORCE)
+# Gentoo: honour the CMAKE_INSTALL_LIBDIR passed in by the package manager
+# (portage's cmake.eclass pre-loads lib64 on multilib profiles) instead of
+# hardcoding prefix/lib.
+set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "Library install directory")
 
 
 # initialization and include paths
