What is "ERROR: Wrong magic number"

R

ravi

Hi all,

I written and compiled a c++ program using g++ no errors or
warning are reported.

But when I run it , reporting an error : ERROR: Wrong magic number.

What is the reason for this error?

anybody had an idea ?

--Ravi.T
 
R

ravi

Hi all,

I written and compiled a c++ program using g++ no errors or
warning are reported.

But when I run it , reporting an error : ERROR: Wrong magic number.

What is the reason for this error?

anybody had an idea ?

--Ravi.T

OS is Linux.gcc3.4.3
 
S

Shadowman

ravi said:
Hi all,

I written and compiled a c++ program using g++ no errors or
warning are reported.

But when I run it , reporting an error : ERROR: Wrong magic number.

What is the reason for this error?

anybody had an idea ?

That sounds like the OS is having a problem running your executable for
some reason -- perhaps the first few bytes of the executable file are
not what they're supposed to be. Could be a problem with the compiler, a
corrupted file, a hardware issue, or something else.

You didn't post any code, but it seems like the problem might be beyond
that.
 
A

Andrew Koenig

I written and compiled a c++ program using g++ no errors or
warning are reported.

But when I run it , reporting an error : ERROR: Wrong magic number.

What is the reason for this error?

Either you didn't link it, or the file you are executing is not the one you
think it is.
 
J

James Kanze

Either you didn't link it, or the file you are executing is
not the one you think it is.

He didn't give a too many details, but in a lot of Unix
distributions today, the default $PATH doesn't have . in it
(which is as it should be for non-developers). And I find a lot
of files have the x bit set when they shouldn't. Combine the
two, and that could very easily explain his symptoms.

Depending on the shell being used, either "type command" or
"which command" can be used to see which executable is actually
being found. More generally, however, when testing a just built
executable, it's usually preferable to invoke it with
../filename. (Or maybe I just believe this because so many of my
test programs are called simply test:), and even with . in the
path, test and ./test invoke different things.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top