GCC在Alpine Linux中找不到stdio.h [英] GCC can't find stdio.h in Alpine Linux

查看:715
本文介绍了GCC在Alpine Linux中找不到stdio.h的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在全新的Alpine Linux中,我通过以下方式安装了GCC

  apk add --update-cache gcc 

但还是一个简单的程序

  #include< stdio.h> 

int main(int argc,char * argv []){
返回0;
}

已编译并带有消息



< pre class = lang-none prettyprint-override> 致命错误:stdio.h:没有这样的文件或目录


解决方案

除GCC之外,还安装 libc-dev ,或仅安装 build-base strong>( alpine-sdk 可能是一个过大的杀伤力)。要安装,请运行以下命令:

  apk add libc-dev 

您需要单独安装,因为在Alpine Linux中,GCC软件包不依赖 libc- dev 有充分的理由


您可以使用gcc编译没有libc的东西,例如管理程序固件等。


August Klein还指出,在Debian中,GCC仅出于相同的原因推荐 libc-dev (但大多数人不这样做-无安装建议)。


In a fresh Alpine Linux I installed GCC by

apk add --update-cache gcc

but still a simple program

#include <stdio.h>

int main(int argc, char *argv[]) {
    return 0;
}

compiled with message

fatal error: stdio.h: No such file or directory

解决方案

Install libc-dev in addition to GCC, or just install build-base for everything (alpine-sdk is probably an overkill). To install run the following command:

apk add libc-dev

You need to install it separately because in Alpine Linux, the package GCC doesn't depend on libc-dev for good reason:

You can use gcc to compile things without libc, for example hypervisors firmware etc.

And August Klein also noted that in Debian, GCC only recommends libc-dev for the same reason (but most people don't do --no-install-recommends anyway).

这篇关于GCC在Alpine Linux中找不到stdio.h的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆