判断当前所用C库是glibc还是uclibc

1.准备测试代码

#include <stdio.h>

int main(void)
{
    printf("hello\n");
    return 0;
}

2.使用-v选项,编译

gcc -v test.c

3.分析输出

1.查看头文件目录中,有没有uclibc输出字段中

#include "..." search starts here:
#include <...> search starts here:
 /home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/include
 /home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/include-fixed/uclibc
 /home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/../../../../mips-linux-gnu/include
 /home/hany/work/t40/mips-gcc720-glibc226/bin/../mips-linux-gnu/libc/uclibc/usr/include
End of search list.

2.查看LIBRARY_PATH中有没有uclibc

LIBRARY_PATH=/home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/uclibc/:/home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/../../../../mips-linux-gnu/lib/uclibc/:/home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/:/home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/:/home/hany/work/t40/mips-gcc720-glibc226/bin/../lib/gcc/mips-linux-gnu/7.2.0/../../../../mips-linux-gnu/lib/:/home/hany/work/t40/mips-gcc720-glibc226/bin/../mips-linux-gnu/libc/uclibc/lib/:/home/hany/work/t40/mips-gcc720-glibc226/bin/../mips-linux-gnu/libc/uclibc/usr/lib/
posted @ 2021-10-26 15:53  海林的菜园子  阅读(680)  评论(0编辑  收藏  举报