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

头文件与多源文件是否需同目录?编译执行报错求助

Fixing the "./assignmentgrading3: No such file or directory" Error

Let's work through this issue step by step—missing executable errors are usually easy to track down once you check a few key things. First, a quick recap: you've got a header file plus three C files (main grading system, student module, teacher module) all in an assignmentgrading3 folder, and you're hitting this error when trying to run your program from the Debug subdirectory.

Here's what to check:

  • First, confirm the executable actually exists in that Debug folder
    Run this command to list all contents of the directory you're trying to run from:

    ls -la /Users/alessafaria/Documents/assignmentgrading3/assignmentgrading3/Debug
    

    Look for a file named assignmentgrading3. If it's not there, your build failed somewhere—check your compilation commands (if building manually) or your IDE's build logs for errors like missing includes, undefined functions, or syntax issues.

  • Make sure you're compiling all your C files correctly (manual builds)
    If you're using gcc or clang in the terminal, you need to link all three .c files together and explicitly set the output name. For example, if your files are main.c, student.c, teacher.c, and grading.h, your compile command should look like this:

    gcc main.c student.c teacher.c -o assignmentgrading3
    

    The -o assignmentgrading3 flag tells the compiler to name your executable exactly that. If you skip this flag, the compiler will output a default executable named a.out—so you'd need to run ./a.out instead of ./assignmentgrading3.

  • Check if you're in the right directory when running the command
    The error shows you're in the Debug folder, but maybe the executable was built in the parent assignmentgrading3 folder instead? Try navigating up one level and checking:

    cd /Users/alessafaria/Documents/assignmentgrading3/assignmentgrading3
    ls -la
    

    If you see assignmentgrading3 here, run ./assignmentgrading3 from this location instead.

  • Fix execute permissions if the file exists but won't run
    If you see the executable listed in the directory but still get the error, it might not have permission to run. Fix that with this command:

    chmod +x /Users/alessafaria/Documents/assignmentgrading3/assignmentgrading3/Debug/assignmentgrading3
    

    Then try running the program again.

  • Verify your IDE's build settings (if using an IDE like Xcode)
    If you're using an IDE to build, double-check where it's outputting the executable. Sometimes IDEs put built files in hidden directories (like Xcode's DerivedData folder) instead of the Debug folder you're looking in. Make sure your target's build settings are set to output the executable with the name assignmentgrading3 into the expected Debug directory.

内容的提问来源于stack exchange,提问作者Alessa Faria

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 04:22:23