gpt4 book ai didi

c - Bash for Windows 10 gcc 不会编译粘贴到根目录中的 c 文件

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:04 25 4
gpt4 key购买 nike

顾名思义,如果我把一个写在别处的c文件粘贴到Linux子系统的根目录下,我无法编译它。

我做了一个测试,我制作了两个不同名称的 hello world 程序:一个在 vi 中,我可以从 bash 界面进入,另一个在其他地方。当我编译用 vi 制作的那个时,它运行良好。尝试对在别处制作的文件执行此操作(在将其粘贴到根目录后),然而,结果如下:

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

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

最佳答案

Do not change Linux files using Windows apps and tools!

假设您所说的“将在其他地方编写的 C 文件粘贴到 Linux 子系统的根目录中”的意思是您将文件粘贴到 %localappdata%\lxss 中,这是 明确不受支持。在此区域中通过 Linux 系统调用本地创建的文件具有 UNIX 元数据,而使用 Windows 工具本地创建的文件则没有。

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


引自此答案顶部链接的 Microsoft 博客(强调原文):

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

关于c - Bash for Windows 10 gcc 不会编译粘贴到根目录中的 c 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44312116/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com