Home > Mobile >  "No such file or directory" Why does my c build file can't build my exe if my files a
"No such file or directory" Why does my c build file can't build my exe if my files a

Time:06-12

Why is my build code won't working informing that my file is not acessible if it is in the right folder and my c debugger work as well, finding no errors?

This is my build file:

set files=src\glad.c src\main.c set libs=C:\Users\Ozzy\Documents\projects\c\lib\SDL2main.lib C:\Users\Ozzy\Documents\projects\c\lib\SDL2.lib C:\Users\Ozzy\Documents\projects\c\lib\freetype.lib

CL /Zi /I C:\Users\Ozzy\Documents\projects\c\include %files% /link %libs% /OUT:mygame.exe

    OpenGL loader generated by glad 0.1.35 on Fri Jun 10 23:39:07 2022.

    Language/Generator: C/C  
    Specification: gl
    APIs: gl=3.3
    Profile: core
    Extensions:
        
    Loader: True
    Local files: False
    Omit khrplatform: False
    Reproducible: False

    Commandline:
        --profile="core" --api="gl=3.3" --generator="c" --spec="gl" --extensions=""
    Online:
        https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl=3.3
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glad.h>

Print of the error and folder tree

CodePudding user response:

From your screenshot I can see that the glad directory is next to main.c.

When including files, you can use either quotes ("") or angle brackets (<>), and they behave differently. The exact behavior depends on the compiler you are using and the settings for that compiler, but with cl.exe the default behavior is:

  • <>: Search within your include paths (which can be set using the /I flag).
  • "" Search relative to the location of the including file. If that doesn't work, fall back to the include paths.

So if you replace:

#include <glad/glad.h>

With:

#include "glad/glad.h"

Then it should work.

Here's some more information about how the #include directive works in cl.exe/MSVC.

  •  Tags:  
  • c
  • Related