I was able to reproduce this issue with a simple case (shown below). The problem in particular is that the output of compiling my main C file is a file with format data (returned by running file on the file). When the file is run, the command line gives the error cannot execute binary file: Exec format error.

The file, main.c contains the following code:

#include <stdlib.h>

int main(int argc, char* argv[]) 
    return 0;

I am using this command to compile the code: gcc main.c -o main.

Output of gcc --version:

gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Any thoughts, comments, or ideas are appreciated.

  • I still don't know why this was happening, but I was able to compile properly from a different computer with the same (or similar) specs.
    – Maria
    Apr 18, 2016 at 4:17
  • How are you running the compiled program? I'd suggest always using ./main just so that you don't pick up main from anywhere else from $PATH Apr 18, 2016 at 7:47
  • Yes, that is how I run my executables on linux. The issue is that using file on an executable should give you a whole bunch of information about the bitness and the file format, but running file on main gives the output data (i.e. not an executable file). I think @gslin's answer is correct.
    – Maria
    Apr 18, 2016 at 21:21

1 Answer 1


Your gcc might be corrupted, try to re-install gcc-4.8:

apt-get install --reinstall gcc-4.8
  • I agree this is likely the issue. I don't have permission, but I'll let an admin know. Thanks.
    – Maria
    Apr 18, 2016 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.