You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C项目模块化编译报错:cannot find modules/impl: Permission denied

C语言模块化项目编译权限错误原因解析

编译命令与报错信息

PS C:\Users\muril\OneDrive\Desktop\projeto-sgbd-master> gcc main.c modules/impl* -I modules/includes
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find modules/impl: Permission denied collect2.exe: error: ld returned 1 exit status

项目文件结构

|---project/
|---main.c
|---modules/
|   |---include/
|       |---module1.h
|       |---modele2.h
|   |---impl/
|       |---modele1.c
|       |---modele2.c

错误原因

  1. 通配符解析错误:在PowerShell环境中,modules/impl*会优先匹配到modules/impl这个目录,而非目录下的.c源文件。GCC试图将目录作为编译输入,操作系统拒绝了这种操作(目录无法被当作源文件处理),因此抛出"Permission denied"错误。
  2. 路径拼写错误:编译命令中指定的头文件路径是modules/includes,但实际项目结构里是modules/include,这个错误会导致后续找不到头文件,不过不是当前权限错误的直接诱因。
  3. 文件名拼写错误:项目里的modele2.h、modele1.c、modele2.c明显是module2.h、module1.c、module2.c的拼写失误,后续编译也会因为找不到正确文件报错。

修正后的编译命令

gcc main.c modules/impl/*.c -I modules/include

内容的提问来源于stack exchange,提问作者Murilo Antonio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 07:39:51