Cygwin Error :: Cannot execute binary file


Hi!

I am trying to compile a C PROGRAM (Echo1.C) on Cygwin using GCC Compiler.  I type the following command to compile it:

h4x0r@PC161035812295 /cygdrive/D/C-C++_Scripts
# gcc -c Echo1.C -o Echo1

This works fine, and it creates an executable called "Echo1", but when I try to execute this, I get the following error:

h4x0r@PC161035812295 /cygdrive/D/C-C++_Scripts
# Echo1
./Echo1: ./Echo1: cannot execute binary file

Is anything wrong with my approach?  Please advise!

Thanks in advance.

Echo1.C
LVL 6
Ritesh_GargAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rkursemConnect With a Mentor Commented:
Hi,

It is most likely because your program includes an old cygwin1.dll when started.
Have you upgraded cygwin or is it installed from scratch?

0
 
heygarCommented:
If you are running Win7 and probably Vista, the easiest thing to do is compile the code as an Administrator.  Right-click on your cygwin shortcut, pick the "Run as Administrator" option, agree to the warning, then issue your gcc command to compile your code (in the newly opened "Administrative" Cygwin command window).

Once it's compiled in this environment, it should run.
0
 
Ritesh_GargAuthor Commented:

Yes, You're right.  The thing which was happening was that I had GCC Compiler for linux based system.  Then I reinstalled CYGWIN with its inbuilt CC Compiler Option.  And then I issued the command "cc echo1.c -o echo1", so it created windows executable "echo1.exe" instead of linux based executable "echo1" which was the thing happening previously.  Hence, I was able to run this executable, and see the output.  It really worked, and worked very well.

Thanks A Million for your valuable suggestions.

Keep up the good work!
0
 
Ritesh_GargAuthor Commented:

Hi!

As I said in my previous comment, I had GCC compiler for linux-based system, I changed it to the default Cygwin CC Compiler, and I was able to run all of my C Scripts.

I've attached these scripts and the log for you guys to have a look.

Once again, thanks very much for all your valuable suggestions.

Keep up the good work!

Echo1.C
Echo2.C
Cygwin-cc-Log----04-07-2010.LOG
0
All Courses

From novice to tech pro — start learning today.