Skip to content

Instantly share code, notes, and snippets.

@1duo
Last active April 23, 2024 15:58
Show Gist options
  • Star 67 You must be signed in to star a gist
  • Fork 20 You must be signed in to fork a gist
  • Save 1duo/38af1abd68a2c7fe5087532ab968574e to your computer and use it in GitHub Desktop.
Save 1duo/38af1abd68a2c7fe5087532ab968574e to your computer and use it in GitHub Desktop.
Install CMake on CentOS 7.

Download CMake from: https://cmake.org/download/

wget https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz

Compile from source and install

tar zxvf cmake-3.*
cd cmake-3.*
./bootstrap --prefix=/usr/local
make -j$(nproc)
make install

Validate installation

cmake --version

cmake version *.*.*
CMake suite maintained and supported by Kitware (kitware.com/cmake).
@risbo
Copy link

risbo commented Nov 7, 2018

I did all but the version is 2.8
I dont kno why dont set up
image

@1duo
Copy link
Author

1duo commented Nov 20, 2018

I did all but the version is 2.8
I dont kno why dont set up
image

Looks like you installed to /usr/local/bin/cmake, try invoke which the full path. Your current cmake might still linked to the previous installation.

/usr/local/bin/cmake --version

Copy link

ghost commented May 14, 2019

try cmake3 --version

@aspsda
Copy link

aspsda commented Aug 25, 2019

I did all but the version is 2.8
I dont kno why dont set up
image

For centos, you can create shortcut to /usr/sbin/cmake using this command:

ln -s /folderorfile/link/will/point/to /name/of/the/link

@ivikramsahu
Copy link

I think below command also works perfectly! which is simplest way to install

yum install cmake

@LRDPRDX
Copy link

LRDPRDX commented Mar 19, 2020

Worked as expected in RHEL 7. Although I didn't install the default version (with yum install cmake etc.) at all.

@beevans
Copy link

beevans commented May 11, 2020

I needed to run:
source ~/.bashrc
before it would work correctly. I was getting "CMake Error: Could not find CMAKE_ROOT !!!" errors.

@duanyzhi
Copy link

change:
./bootstrap --prefix=/usr/local
to
./bootstrap --prefix=/usr/

@Gwapogeorge
Copy link

When i tried this using SUDO, it did not work correctly...

However ...

When i logged in as ROOT and tried it it worked...

Go Figure.

@Gwapogeorge
Copy link

And ... when i did it with SUDO, i got the CMAKE_ROOT error as well.

And ... when i did a CMake --version it gave me the old version, two point something.

When completed as ROOT, the error went away, and the version showed as: cmake version 3.12.3

LOG IN AS ROOT!

@qwertynik
Copy link

Thanks for sharing the steps @1duo

@ArunTS96
Copy link

ArunTS96 commented Feb 4, 2022

How do we uninstall or cleanup if we have installed cmake via the above steps

@MinBio
Copy link

MinBio commented Mar 4, 2022

thanks for sharing @1duo. i did find two cmake paths and find CMAKE_BIN in R points to /usr/bin/cmake. but the include library shows /usr/local/bin. after changing the name in /usr/bin/cmake. it works. you are awesome!

@alphanso
Copy link

make uninstall incase something goes wrong

@Matoran
Copy link

Matoran commented Feb 17, 2023

yum uninstall cmake is you already have version 2.8, it will remove it.

@mrdashuai
Copy link

"CMake Error: Could not find CMAKE_ROOT !!!"
Having Error. However, after rebooting the CentOS system. It works well.

@Rootsramos
Copy link

Have an error with the install command

collect2: error: ld returned 1 exit status
make[2]: *** [Utilities/cmcurl/CMakeFiles/LIBCURL.dir/build.make:88: Utilities/cmcurl/LIBCURL] Error 1
make[1]: *** [CMakeFiles/Makefile2:1533: Utilities/cmcurl/CMakeFiles/LIBCURL.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Any idea to fix it?

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment