glibc 라이브러리 버젼 확인 방법

glibc 라이브러리

GNU C 라이브러리(GLIBC)는 리눅스와 UNIX 계열 운영 체제의 핵심 구성 요소다. 프로그램이 운영 체제와 소통할 수 있게 해주는 필수적인 인터페이스를 제공하며, 개발자가 효율적으로 시스템 레벨 프로그래밍을 작성할 수 있는 환경을 제공한다. 레드햇, CentOS, 우분투 등 다양한 리눅스 배포판에서 찾아볼 수 있다.

glibc explained from Wikipedia.com
glibc explained from Wikipedia.com

버젼 확인 방법 세가지

1. ldd 명령 사용하기

가장 쉽고 빠른 방법은 리눅스 시스템의 쉘에서 ldd 명령을 사용하는 방법이다. --version 옵션과 함께 실행시, 아래와 같이 라이브러리의 버젼이 출력된다.

[ec2-user@ip-10-0-0-18 ~]$ ldd --version
ldd (GNU libc) 2.34
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

2. 라이브러리 직접 실행하기

시스템의 libc.so.6 파일을 직접 실행해도, 라이브러리에 대한 정보를 출력에서 확인할 수 있다. 실행하는 파일이 libc.so가 아니라 libc.so.6임에 주의. 파일 위치를 모른다면, whereis 등의 명령어로 파일 경로를 찾은 후 실행한다.

[ec2-user@ip-10-0-0-18 ~]$ whereis libc.so.6
libc.so.6: /usr/lib64/libc.so.6
[ec2-user@ip-10-0-0-18 ~]$ ls -al /usr/lib64/libc.so.6
-rwxr-xr-x. 1 root root 2385544 Oct 24 07:56 /usr/lib64/libc.so.6
[ec2-user@ip-10-0-0-18 ~]$ /usr/lib64/libc.so.6
GNU C Library (GNU libc) stable release version 2.34.
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 11.4.1 20230605 (Red Hat 11.4.1-2).
libc ABIs: UNIQUE IFUNC ABSOLUTE
For bug reporting instructions, please see:
<https://www.gnu.org/software/libc/bugs.html>.

3. 라이브러리 사용해 정보 출력하기

라이브러리를 직접 사용해, 버젼 정보를 출력하는 프로그램을 작성하는 귀찮은 방법으로도(?) 정보를 확인할 수 있다. 이렇게까지 해야 하나 싶지만, 가능하다는 것만 알아두자.

#include <stdio.h>
#include <gnu/libc-version.h>

int main() {
    printf("GLIBC Version: %s\n", gnu_get_libc_version());
    return 0;
}

굳이 위의 코드를 작성하고, 컴파일해서 실행해보면 너무 당연하게도 버젼 정보가 나온다.

[ec2-user@ip-10-0-0-18 ~]$ vim showmetheversion.c
[ec2-user@ip-10-0-0-18 ~]$ gcc -o showmetheversion showmetheversion.c
[ec2-user@ip-10-0-0-18 ~]$ ./showmetheversion
GLIBC Version: 2.34

요약

glibc 버젼은 쉘에서 그냥 ldd 명령으로 쉽게 확인하자.

+ There are no comments

Add yours

이 사이트는 Akismet을 사용하여 스팸을 줄입니다. 댓글 데이터가 어떻게 처리되는지 알아보세요.