无法在ubuntu上编译C代码. (#include错误) [英] Having trouble compiling C code on ubuntu. (#include errors)
问题描述
我正在尝试在最新版本的ubuntu上编译C程序,目的是稍后将编译后的程序放在另一台计算机上.但是,当我使用gcc prog.c -o prog进行编译时,出现错误:致命错误:asm/page.h:没有这样的文件或目录"这是标头:
I'm trying to compile a C program on the newest version of ubuntu, for the purpose of putting the compiled program on another machine later. However, when I compile with gcc prog.c -o prog, I get an error: "fatal error: asm/page.h: No such file or directory" Here are the headers:
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <limits.h>
#include <signal.h>
#include <unistd.h>
#include <sys/uio.h>
#include <sys/mman.h>
#include <asm/page.h>
#include <asm/unistd.h>
我在#include处出错.它显示致命错误:asm/page.h:没有这样的文件或目录.就像我说的那样,我只是想对其进行编译.有什么办法让我得到丢失的标题或其他东西吗?谢谢.
I get an error at #include . It says fatal error: asm/page.h: No such file or directory. Like I said, I'm just looking to compile it. Is there a way for me to get the missing header or something? Thanks.
推荐答案
这些头文件不丢失,它们已被移动. ubuntu打包程序四处移动,以前在'/usr/include/asm'中的头文件的位置现在在'/usr/include/asm-generic'
These header files are not missing they have been moved. The ubuntu packagers moved things around and the location of the header files that used to be in '/usr/include/asm' are now in '/usr/include/asm-generic '
要修复,只需添加一个链接:
To fix, just add a link:
sudo ln -s/usr/include/asm-generic/usr/include/asm
sudo ln -s /usr/include/asm-generic /usr/include/asm
...或者,也许您可能缺少构建必需的东西.这是在linux中编译Code所必需的. 安装build-essential
... or, maybe you are probably lacking build-essential. This is necessary to compile Code in linux . install build-essential
sudo apt-get install build-essential
sudo apt-get install build-essential
现在重新创建正确的链接:
Now recreate the proper link:
sudo ln -s/usr/include/asm-generic/usr/include/asm
sudo ln -s /usr/include/asm-generic /usr/include/asm
Build-essential应该安装/usr/include/asm-generic文件夹.如果您没有这样的文件夹,请重新安装build-essentials并确认该文件夹存在.
Build-essential should install a /usr/include/asm-generic folder. If you lack such a folder reinstall build-essentials and verify the folder exists.
/usr/include/asm-generic文件夹是否存在?
Does the /usr/include/asm-generic folder exist?
它是由build-essentials安装的,但检查它是安装它的依赖项.
It is installed by build-essentials but examining it it is a dependency that installs it.
如果/usr/include/asm-generic不存在,请尝试安装或重新安装linux-libc-dev.
if /usr/include/asm-generic does not exist, try to install or reinstall linux-libc-dev.
那应该创建asm-generic文件夹.如果是这样,请删除该旧链接,然后将asm重新链接为asm-generic.
That should create the asm-generic folder. If so delete that old link and relink asm to asm-generic.
这篇关于无法在ubuntu上编译C代码. (#include错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!