diff --git a/Others/glibc/README.md b/Others/glibc/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e0f214108fdbf72630c2721a09ba6a7f34d30cf3 --- /dev/null +++ b/Others/glibc/README.md @@ -0,0 +1,84 @@ +# Quick reference + +- The official Glibc docker image. + +- Maintained by: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative). + +- Where to get help: [openEuler CloudNative SIG](https://gitee.com/openeuler/cloudnative), [openEuler](https://gitee.com/openeuler/community). + +# Glibc | openEuler +Current Glibc docker images are built on the [openEuler](https://repo.openeuler.org/). This repository is free to use and exempted from per-user rate limits. + +The GNU C Library project provides the core libraries for the GNU system and GNU/Linux systems, as well as many other +systems that use Linux as the kernel. These libraries provide critical APIs including ISO C11, POSIX.1-2008, BSD, +OS-specific APIs and more. These APIs include such foundational facilities as open, read, write, malloc, printf, +getaddrinfo, dlopen, pthread_create, crypt, login, exit and more. + +Learn more about Glibc on [Glibc Website](https://sourceware.org/glibc/)⁠. + +# Supported tags and respective Dockerfile links +The tag of each `glibc` docker image is consist of the version of `glibc` and the version of basic image. The details are as follows +| Tag | Currently | Architectures | +|----------|-------------|------------------| +|[2.41-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/glibc/2.41/24.03-lts-sp1/Dockerfile)| glibc 2.41 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + +# Usage +In this usage, users can select the corresponding `{Tag}` based on their requirements. + +- Pull the `openeuler/glibc` image from docker + + ```bash + docker pull openeuler/glibc:{Tag} + ``` + +- To run and enter the glibc container with an interactive shell: + + ```bash + docker run -it --rm openeuler/glibc:{Tag} bash + ``` + +- Write a test program + Here is an example: + ```bash + #include + #include + + int main() { + printf("Hello, Glibc 2.41!\n"); + printf("Current Glibc version: %s\n", gnu_get_libc_version()); + return 0; + } + ``` + You'll need to hava GCC installed first to compile this program. + ``` + dnf install -y gcc + ``` + +- Compile the program against the new glibc version + + Create a simple C program (e.g., test.c) to verify Glibc functionality. The glibc is installed at `/usr/local/glibc`, specify the compiler options with the glibc directory. + + ```bash + gcc test.c -o test_program \ + -I/usr/local/glibc/include \ + -Wl,--rpath=/usr/local/glibc/lib \ + -Wl,--dynamic-linker=/usr/local/glibc/lib/ld-linux-aarch64.so.1 + ``` + This compilation command targets the aarch64 platform, you need to modify the dynamic linker path to match the target platform. + + After successful compilation, execute the binary to verify the output message: + ``` + ./test_program + ``` + +- Key Parameter Description: + + | Parameter | Function | + |----------|-------------| + | -I/usr/local/glibc/include | Specifies the header file path of the new Glibc version. | + | -Wl,--rpath=/usr/local/glibc/lib | Priorities loading libraries from this path during runtime. | + | -Wl,--dynamic-linker=/usr/local/glibc/lib/ld-linux-aarch64.so.1 | Specifies the new version dynamic linker. | + + +# Question and answering +If you have any questions or want to use some special features, please submit an issue or a pull request on [openeuler-docker-images](https://gitee.com/openeuler/openeuler-docker-images). \ No newline at end of file diff --git a/Others/glibc/doc/image-info.yml b/Others/glibc/doc/image-info.yml new file mode 100644 index 0000000000000000000000000000000000000000..effeeb01ec407cc9756d7841061264037e90298d --- /dev/null +++ b/Others/glibc/doc/image-info.yml @@ -0,0 +1,74 @@ +name: glibc +category: others +description: GNU C库(glibc)项目为GNU系统、GNU/Linux系统以及众多以Linux为内核的其他系统提供核心库支持。 +environment: | + 本应用在Docker环境中运行,安装Docker执行如下命令 + ``` + yum install -y docker + ``` +tags: | + glibc镜像的Tag由其版本信息和基础镜像版本信息组成,详细内容如下 + + | Tag | Currently | Architectures | + |----------|-------------|------------------| + |[2.41-oe2403sp1](https://gitee.com/openeuler/openeuler-docker-images/blob/master/Others/glibc/2.41/24.03-lts-sp1/Dockerfile)| glibc 2.41 on openEuler 24.03-LTS-SP1 | amd64, arm64 | + +download: | + 拉取镜像到本地 + ``` + docker pull openeuler/glibc:{Tag} + ``` + +usage: | + - 进入容器交互式终端 + ``` + docker run -it --rm openeuler/glibc:{Tag} bash + ``` + 用户可根据自身需求选择对应版本的{Tag}。 + + - 编写测试程序 + 创建测试程序(如test.c)验证Glibc功能 + ``` + #include + #include + + int main() { + printf("Hello, Glibc 2.41!\n"); + printf("Current Glibc version: %s\n", gnu_get_libc_version()); + return 0; + } + ``` + 编译前需确保安装GCC: + ``` + dnf install -y gcc + ``` + + - 使用新版本的glibc依赖编译程序 + + 新版本glibc安装路径为:`/usr/local/glibc` + ``` + gcc test.c -o test_program \ + -I/usr/local/glibc/include \ + -Wl,--rpath=/usr/local/glibc/lib \ + -Wl,--dynamic-linker=/usr/local/glibc/lib/ld-linux-aarch64.so.1 + ``` + + 编译完成后,可以运行一下编译后的二进制文件: + ``` + ./test_program + ``` + + - 关键参数说明 + + | Parameter | Function | + |----------|-------------| + | -I/usr/local/glibc/include | 指定新版Glibc头文件路径. | + | -Wl,--rpath=/usr/local/glibc/lib | 运行时优先加载该路径下的库文件. | + | -Wl,--dynamic-linker=/usr/local/glibc/lib/ld-linux-aarch64.so.1 | 指定新版动态链接器, 这是aarch64的示例,其他平台需要替换为对应平台的路径. | + +license: LGPL +similar_packages: + - Musl libc: Musl libc 是一个轻量级、快速且符合标准的 C 标准库(C library) 实现,专为 Linux 系统 设计。 +dependency: + - kernel-headers + - bison \ No newline at end of file diff --git a/Others/glibc/doc/picture/logo.png b/Others/glibc/doc/picture/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..e4d062c4e7fee2499e33114a6b72b13feeb2cb82 Binary files /dev/null and b/Others/glibc/doc/picture/logo.png differ