Bash for Windows 10 gcc不会编译粘贴到根目录中的c文件 [英] Bash for Windows 10 gcc won't compile c files pasted into the root directory

查看:190
本文介绍了Bash for Windows 10 gcc不会编译粘贴到根目录中的c文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示,如果我将其他地方写入的c文件粘贴到Linux子系统的根目录中,我无法编译它。

我做了一个测试,在这个测试中,我制作了两个不同标题的hello world程序:一个是vi,我可以从bash界面进入,另一个在其他地方。当我编译vi中的一个时,它运行良好。然而,试图为其他地方(在将其粘贴到根目录之后)这样做的结果导致:

  gcc :error:helloWorld2.c:输入/输出错误
gcc:致命错误:无输入文件
编译终止

对此有任何帮助,我们将不胜感激。

不要使用Windows应用程序和工具更改Linux文件!



假设你的意思是将其他地方写入的C文件粘贴到Linux子系统是将你的文件粘贴到%localappdata%\lxss 中,这是显式不支持。通过Linux系统调用本地创建的文件具有UNIX元数据,使用Windows工具本地创建的文件没有。



使用 / mnt / c (等等)从Linux访问您的Windows文件;不要尝试从Windows修改Linux文件。






引用来自此答案顶部的Microsoft博客因此,请务必遵循这两条规则,以避免丢失文件和/或破坏您的数据:


  • 请使用Windows工具和Linux工具将您的Windows文件系统中的文件存储到您的Windows文件系统中

  • 不要从Windows应用程序,工具,脚本或控制台创建/修改Linux文件



As the title suggests, if I paste a c file written somewhere else into the root directory of the Linux Subsystem, I can't compile it.

I did a test where I made two differently titled hello world programs: one in vi that I can get into from the bash interface, and one elsewhere. When I compiled the one made in vi, it worked fine. Trying to do so for the one made elsewhere (after pasting it into the root directory), however, resulted in this:

gcc: error: helloWorld2.c: Input/output error
gcc: fatal error: no input files
compilation terminated

Any help with this would be much appreciated.

解决方案

Do not change Linux files using Windows apps and tools!

Assuming what you meant by "paste a C file written somewhere else into the root directory of the Linux subsystem" is that you pasted your file into %localappdata%\lxss, this is explicitly unsupported. Files natively created via Linux syscalls in this area have UNIX metadata, which files natively created with Windows tools don't have.

Use /mnt/c (and the like) to access your Windows files from Linux; don't try to modify Linux files from Windows.


Quoting from the Microsoft blog linked at the top of this answer (emphasis from the original):

Therefore, be sure to follow these two rules in order to avoid losing files, and/or corrupting your data:

  • DO store files in your Windows filesystem that you want to create/modify using Windows tools AND Linux tools
  • DO NOT create / modify Linux files from Windows apps, tools, scripts or consoles

这篇关于Bash for Windows 10 gcc不会编译粘贴到根目录中的c文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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