6

I am trying to build and install a library on 64-bit CentOS 7.2. For this purpose I am running

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..

sudo make install

When I run the above commands I found that the installed library is in /usr/lib instead of /usr/lib64. Ideally, when I am compiling on a 64-bit Linux machine the installation directory is /usr/lib64.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
Zubair-Safenet
  • 141
  • 1
  • 9
  • See [config.site for vendor libs on Fedora x86_64](https://stackoverflow.com/q/46847939/608639), [Incorrect @libdir@ when building *.pc using config.site?](https://stackoverflow.com/q/47124066/608639) and [Issue 1510073, Autoconf does not honor libdir in config.site for "libdir= @libdir@" in *.pc file](https://bugzilla.redhat.com/show_bug.cgi?id=1510073) in Fedora's issue tracker. Red Hat drives Fedora and CentOS so it applies to all of them. It sounds like CMake is having the same troubles as Autotools. – jww Apr 03 '18 at 09:19
  • 2
    It is up to the project where it installs things. If project uses [GNUInstallDirs](https://cmake.org/cmake/help/v3.4/module/GNUInstallDirs.html) CMake module, you may adjust `LIBDIR` variable for change libraries' installation directory: `cmake -DLIBDIR=/usr/lib64 <... other-cmake-parameters>`. – Tsyvarev Apr 03 '18 at 09:51
  • @Tsyvarev you were very close but the variable name was actually `CMAKE_INSTALL_LIBDIR` – ceztko Jan 04 '21 at 17:41

1 Answers1

5

@Tsyvarev suggested it in the comments but the variable he mentioned was not correct. This did the trick for me:

cmake -DCMAKE_INSTALL_LIBDIR=lib <more defines> ..

It is documented in CMake GNUInstallDirs page. Also consider the project you're building, if its 3rd party, may override the end up installation directory by this or other means.

ceztko
  • 14,736
  • 5
  • 58
  • 73