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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rkursemCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.