Microsoft 社는 2022년 6월 15일 Internet Explorer 11의 지원을 종료했습니다.

cmake-3.9.6 on CentOS 5.8

제목

cmake-3.9.6 on CentOS 5.8

공식 홈페이지 : https://cmake.org/

0. 주의사항

cmake v3.10 부터는 GCC 4.8.1 이상을 요구하기 때문에 CentOS 5.8 순정 gcc (4.1.2) 로 최신버전(cmake-3.27.3)을 설치할 수 없다.

yum 저장소를 CentOS 5.11 로 변경해서 gcc 4.4 를 설치한 경우도 마찬가지이다.

devtools-2 에서 gcc 를 4.8.2 를 설치했다고 하더라도 glibc 혹은 kernel 버전 때문에 역시나 안된다.

1. 준비작업

1.1. 다운로드

https://cmake.org/files/ 에서 다운로드 한다.

CentOS 5.8 에서 직접 다운로드 할 수 없고, 다른 장비에서 다운로드 한 파일을 sftp 따위로 올려야 한다.

curl 이든 wget 이든 안되고, wget 에 "--no-check-certificate" 을 추가해도 안된다.

curl -O https://cmake.org/files/v3.9/cmake-3.9.6.tar.gz

다만, 필자가 작성한 다른 글에 따라 wget 을 설치했다면, 다음과 같이 할 수도 있다.

/opt/wget-1.21.4/bin/wget \
--no-check-certificate \
https://cmake.org/files/v3.9/cmake-3.9.6.tar.gz

1.2. gcc, g++ 및 make 설치

yum install gcc gcc-c++ make -y

2. 컴파일 및 설치

설치 디렉토리(--prefix) 는 알아서 변경한다.

$ mkdir -p logs/cmake-3.9.6
$ tar xvfz cmake-3.9.6.tar.gz > logs/cmake-3.9.6/tar.`date +%Y%m%d.%H%M%S`.log 2>&1
$ cd cmake-3.9.6
$ ./configure --prefix=/opt/cmake-3.9.6 > ../logs/cmake-3.9.6/config.`date +%Y%m%d.%H%M%S`.log 2>&1
$ make > ../logs/cmake-3.9.6/make.`date +%Y%m%d.%H%M%S`.log 2>&1
$ make install > ../logs/cmake-3.9.6/install.`date +%Y%m%d.%H%M%S`.log 2>&1

3. 적용

3.1. 현재 환경에 적용

현재 환경에서는 다음과 같이 적용한다.

$ export PATH=/opt/cmake-3.9.6/bin:${PATH}

3.2. 현재 로그인한 사용자에게 적용

현재 로그인한 사용자에게 적용하려면, ".bash_profile" 파일의 끝에 위의 내용을 추가한다.

3.3. 시스템 전체에 적용

"/etc/bashrc" 파일에 PATH 환경변수를 변경한다.

export PATH=/opt/cmake-3.9.6/bin:${PATH}

4. 문제해결

4.1. C++ 컴파일러를 찾을 수 없다는 에러

Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.

다음의 경우에 발생한다.

  • GCC 4.8.1 미만에서 cmake v3.10 이상을 컴파일 하려고 하는 경우
  • g++ 혹은 c++ 를 찾을 수 없는 경우

cmake-3.9.6 이하 버전을 사용해야 한다.

g++ 를 설치한다.

yum install gcc-c++ -y

4.2. SOCK_NONBLOCK 등이 정의되어 있지 않다는 에러

cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c:530:46: error: ‘SOCK_NONBLOCK’ undeclared (first use in this function)
peerfd = uv__accept4(sockfd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
^
cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c:530:46: note: each undeclared identifier is reported only once for each function it appears in
cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c:530:60: error: ‘SOCK_CLOEXEC’ undeclared (first use in this function)
peerfd = uv__accept4(sockfd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
^
cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c: In function ‘uv__recvmsg’:
cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c:689:33: error: ‘MSG_CMSG_CLOEXEC’ undeclared (first use in this function)
rc = recvmsg(fd, msg, flags | MSG_CMSG_CLOEXEC);
^
cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c: In function ‘uv__dup2_cloexec’:
cmake-3.27.3/Utilities/cmlibuv/src/unix/core.c:1062:26: error: ‘O_CLOEXEC’ undeclared (first use in this function)
r = dup3(oldfd, newfd, O_CLOEXEC);

glibc 버전이 낮아서 SOCK_NONBLOCK 등을 지원하지 않기 때문이다.

devtools-2 에서 gcc 4.8.2 를 설치하고, cmake-3.27.3 을 설치하려고 시도한 경우에 발생한다.

cmake-3.9.6 이하 버전을 사용해야 한다.

제목

첨부파일