Sublime Forum

Sublime Text 3, Build C program -> Error:file not recognized: file format not recognized

#1

Hi,
I am not able run C program with error message “C_Hello: file not recognized: file format not recognized
collect2.exe: error: ld returned 1 exit status”

What I have done is as follows,

  1. Installed MinGW (incl. added environment variable). Tested the compiler gcc exists via cmd.exe.
  2. Made the new Build System and incl. the following codes
    {
    “cmd” : “gcc $file_name -o ${file_base_name} && ${file_base_name}”,
    “selector” : “source.c”,
    “shell”: true,
    “working_dir” : “$file_path”
    }
  3. Wrote the C code and saved as c file. When I build this, error turned up.

I carefully followed the steps from online resources, and now I get stuck on my first-day experience of Sublime Text3. Hopefully any expertise can direct me on the right path. Really appreciated.

Cheers

0 Likes

#2

At a guess the compiler might be getting mad that the file doesn’t have a .c extension so it may assume that it doesn’t know what kind of file it is.

As a side note, the C Single File build system that ships with Sublime comes pre-configured to build and run single file C programs using gcc; trying that build may work better for you (make sure you choose the Run variant).

0 Likes