Search code examples
cgcccompiler-errorscygwincontrolled-folder-access

compiling C program with gcc; Cannot open output file _.exe: no such file or directory


I just started trying to program in C and I've downloaded all kinds of IDE's and compilers and nothing seems to be working. Cygwin keeps giving me this error when i try to compile my program:

C:\Users\Paul\Documents\Timmy
λ gcc -o nutt nutt.c
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: 
cannot open output file nutt.exe: No such file or directory
collect2: error: ld returned 1 exit status.

here is my program

#include <stdio.h>
int main(void) {
    printf("y");
    return 0;
}

I also want to point out that i have this strange issue when i try to use the "save as" features in notepad or notepad++. when i try to save something this way it will bring up an error message saying the file isn't found and to check the file name and try again. both of these issues seem to have occured around the same time, i'm not sure if they are related. I try saving this way by setting the file type to all types and i just type in "something.c" for the name.


Solution

  • I fixed it! thank you guys for trying to help. I fixed it by turning off controlled folder access in my windows defender security center.

    https://answers.microsoft.com/en-us/windows/forum/windows_10-files/cant-save-to-documents-folder-after-fall-creators/b1274473-6dcd-4bbf-8040-6ba1bc79287f

    I can now use the save as features and compile my C source files.

    I kept trying to google stuff about gcc when it was really windows' fault...